In “The Stuff of Thought,” Steven Pinker, a cognitive scientist and a professor at Harvard, listed a few functions of swearing. There’s emphatic swearing, for instance, which is meant to highlight a point, and dysphemistic swearing, which is meant to make a point provocatively.
But swearing is beneficial beyond making your language more colorful. It can also offer catharsis. A study co-authored by Richard Stephens, a senior lecturer in psychology at Keele University, found that swearing can increase your ability to withstand pain. So when you stub your toe and howl an expletive, it might help you tolerate the pain better.