It's normal for young people to want to prove themselves as they enter adulthood. They're all trying to convince themselves and their friends in many ways that they are ahead of the pack and capable of navigating in the adult world. Some are smart enough to do it with good grades, sports and positive achievements while others try to prove their adulthood by smoking, drinking, drugs and sex.
If we could fast forward 20 years, we would see the first group living in nice houses, driving new cars and living comfortable lives while the second group is still struggling to deal with all of the baggage they picked up in their teenage years. Tobacco and drug habits, lack of skills for employment and an old station wagon full of kids.
You're right, teenage sex doesn't make sense to a thinking person, but looking through the hormone fog of their early teens, it's very easy to fall into the trap of sacrificing the long term for instant gratification. Many pay a terrible price for their inability to see that.