It’s obviously about emotion but here’s some evidence to support this. Richard Stevens (the author of the article in The Psychologist) put participants in a painful situation – placing their hand in a bucket of ice cold water. He asked some of the participants to repeat a swear word of their choosing while doing this task. These participants withstood the pain longer than participants who just repeated a neutral word. This suggests that swearing does offer an emotional release and may make difficult situations more tolerable. Furthermore Stevens has found that repeatedly using a swear word reduces its effectualness – it loses its emotional impact.
But what about humour – after all, comedians use swearing a lot? I’ll leave you with the title of a serious research study on the topic (of swear words not humour) ‘Christ fucking shit merde!’ Language preferences for swearing among maximally proficient multilinguals. Did you smile?