Terry Casalou has the answer here I like the most. (Vote #1: Terry Casalou’s answer to Is there any function of swearing?)
Swearing is a form of communication that includes our passion level.
I’d like to dig a little deeper. Why does swearing do that?
Breaking taboos is one mechanism of indicating passion. Not the only one, but certainly one designed to get maximum attention. It correlates with extremity of passion: you’re saying you’re so worked up, you’re prepared to violate a social taboo. It used to be taboos on religion (Goddamn, Zounds = God’s Wounds, Gadzooks = God’s Hooks), then it was taboos on sex (Fuck, Cunt, Jerk). Taboos on excretion (Shit, Piss) have never really gone away. And the taboos vary widely by culture.
There’s some constraints.
- On the one hand, the taboo has to be relevant still. Zounds now sounds ridiculous, and you have the apocryphal anecdotes of kids not brought up religious, and wondering why Jesus Christ is named after a swear word.
- On the other hand, the taboo can’t be so strong that you will trigger genuine revulsion. The taboo on racist discourse is very strong in the US, and there’s good reason for that. Saying “nigger nigger nigger” just so you can show how angry you are or to get a rise out of someone is not really a good idea—although you can see why the alt-right gets their Freedom Of Expression kicks out of it.
Different subcommunities within a language community are going to have different norms of what is acceptable. You need to be aware of those norms, to avoid either getting your head kicked in, or laughed at.