The purpose of words is to be signifiers, to create certain images when the words are said. For some words, they go deeper and tie into certain emotions. When you are angry and feeling pent up, needing to release frustration, such words can help this, creating an outlet.
In a similar vein, a study was conducted where people, after hurting themselves accidentally like stubbing their toe, said a normal word like 'chair' in one instance, and a swear word in another. Saying a swear word helped lessen the pain more than a normal word.
Swearing can be somewhat cathartic, although swearing AT people isn't cool.