Teenagers have a bad reputation. They’re moody, they thrive on drama. They take risks that terrify their parents and seem blithely unaware of the potential consequences of their actions. The reason for this, as scientists have discovered through modern brain-scanning technology, is that the teen brain isn’t fully cooked — it’s still in the process of rewiring and remodeling itself and maturing toward adulthood.

But here’s an intriguing question: Why would the human brain pass through such a seemingly senseless and dangerous — and protracted — phase on its way to maturity? Is there some utility to the vulnerable adolescent brain, or should it be seen only as a hazard?

These are the questions raised by science writer David Dobbs in a fascinating feature in National Geographic. Although most scientific research has focused on adolescents’ deficits and self-destructive impulses, Dobbs highlights work that looks at the upside of the teen brain and the evolutionary needs that drive adolescence.

The teenage brain isn’t just a “work in progress,” Dobbs argues. Rather, it’s adapted to meet specific challenges. He writes:

Over the past five years or so, even as the work-in-progress story spread into our culture, the discipline of adolescent brain studies learned to do some more-complex thinking of its own. A few researchers began to view recent brain and genetic findings in a brighter, more flattering light, one distinctly colored by evolutionary theory. The resulting account of the adolescent brain — call it the adaptive-adolescent story — casts the teen less as a rough draft than as an exquisitely sensitive, highly adaptable creature wired almost perfectly for the job of moving from the safety of home into the complicated world outside.

This view will likely sit better with teens. More important, it sits better with biology’s most fundamental principle, that of natural selection. Selection is hell on dysfunctional traits. If adolescence is essentially a collection of them — angst, idiocy, and haste; impulsiveness, selfishness, and reckless bumbling — then how did those traits survive selection? They couldn’t — not if they were the period’s most fundamental or consequential features.

Dobbs explores the research on changes in the brain’s dopamine system, for example, which is what drives teens to novelty and thrill-seeking, and part of what makes socializing with their peers so overwhelmingly attractive. It’s maddening to the parent, who focuses on the risks while his teen seeks rewards, but evolutionarily speaking, this is exactly what sexually maturing humans should be doing if they are to successfully find mates and create a social network to support child-raising.

Of course, the problem is that, these days, becoming a teen parent is not the typical road to success. Like many hard-wired human imperatives — the genes that spur our bodies to seek and store fat, for example — it is more adapted to our past than to our present. But when humans first evolved, early reproduction was probably advantageous. And in small, tribal groups, the ability to fit in with one’s peers was actually a life-or-death matter — much the way modern teens still tend to view it.

Dobbs’ story covers a lot of other fascinating research; check it out here. And let’s hope this new perspective engenders a little more compassion for teens: they face big challenges, and being treated dismissively (or worse) by adults doesn’t make it easier.

Maia Szalavitz is a health writer at TIME.com. Find her on Twitter at @maiasz. You can also continue the discussion on TIME Healthland’s Facebook page and on Twitter at @TIMEHealthland.