I think that cussing is like yelling, screaming, growling, hissing, etc. with strength, or hitting a punching ball, for instance; so, you're letting steam off, releasing an accumulated bubble of frustrations, anger, fears, pains, grudges, exasperation or extreme tiredness, which are weakening or hampering your actions and thoughts; it helps also to "clean" and activate your breath, your mind, calms down and canalises your inner violence into the required effort.
The curses express most certainly a rebellion against too demanding rules and restrictions (whether through religious or secular laws), unbearable taboos, ill fate and hardship, and it feels like getting rid of these hampering emotional and physical burdens.
Furthermore, the metabolic reactions are prompting the release of the energising substances (adrenaline, etc.) allowing to deal more efficiently with a critical situation.
As to the slurs, they might be the easiest to come, but used too often, at the wrong moment or in the wrong place, they can also offend or hurt other people and, sometimes, yourself (insults can be fined).
or