It is not uncommon in languages for crudeness to serve as an indicator familiarity. In America one might jovially refer to a close friend as a "bastard", "motherfucker", or in certain subcultures use a word no white person except Eminem is allowed to use. I've heard many a young woman address her young female friends as 'cunt' or 'bitch'. Similarly, formality is often used to put distance between yourself and people you don't like, i.e. by calling them "sir".
Formality is used to put a respectful distance between people you don't like, but also people you don't know.
Too much familiarity with someone you don't known is a highly aggressive challenge. "What's up motherfucker" to some guy at the bar won't make any friends and might end in a fight.
As with many things there is quite a bit of nuance to the usage of registers, often differing by region. Opening conversation with strangers using an informal (but not crude) register is common in the US, and consequently the injection of formality can be done with hostile intention. If the hostility is not recognized by the other party the intention can be made clear by the juxtaposition of formality and crudeness. Consider a phrase like "Would you kindly fuck off?".