The Case for Cursing https://nyti.ms/2u1b173 in the New York Times lays out the magic that swearing at the most inappropriate moments can have for people.
Is swearing a ritual? Potentially. If in the moment of extreme stress or pain, the utterance of one of these forbidden words can be a release, that seems to be a small, meaningful, and transgressive ritual. These magic words are passed down, sometimes they change, but their inappropriateness is also their power.
Breaking the taboo through invoking this special word can actually be a catharsis, helping you to tolerate pain and move through a bad experience more quickly.