Naturally we wish to avoid getting out of our depth. But if we are an adolescent pretending to be an adult behind our parents' backs, getting out of our depth is a real and present danger.

Of course to us it doesn't seem like getting out of our depth. All of a sudden we lose our footing and find we are required to swim. But being an adolescent we haven't yet learnt to swim like an adult. So we feel put upon, we feel nasty because we think they are being nasty to us. So naturally we reciprocate and are nasty in return.

Fortunately this has the effect of ending the interaction which is taking us out of our depth and returns us to the shallows.

So adolescent nastiness is functional. Adolescent nastiness stops adolescents from getting out of their depth.