It could give somebody a sense of power in an environment that they feel they need to present themselves in an impressive way around peers.
It can also be used as a defensive language when one is mad or upset.
Socially, swearing has a stigma for being inappropriate, so I could also see it being used as a form of self expression in society.
I suppose it could be a release of emotions through language which is the only benefit I could see from it.