Slavoj Zizek like to talk about dirty jokes as a sort of a way to forge an in-group, or a way to let the guards down.
He mentions it here for example:
https://www.youtube.com/watch?v=Ri0qiAita4s
Jokes are a way to probe and see if the other party is sincere. One example he brings up is how there used to be racial jokes between ex-Yugoslavian countries. They would meet and tell jokes about themselves basically. However as soon as tensions started jokes stopped. So another way to think about, dirty jokes are a bit like a canary in a mine. If jokes are allowed, other party is laughs at jokes, everything is still ok, it means they don't harbor hidden hatred or resentment. As soon as jokes stop, beware. You could be back-stabbed.
Not advocating telling dirty jokes everywhere obviously, just present that particular take on that.