Why can only minorities joke about themselves?

I was explaining to a friend a joke that a black colleague told me at work, like "oh, I can't pay under the table because I'm already black" (pay under the table in italian is litteraly= pay in black lol)

At some point, my friend explained that only black people can joke about black people, and he gave me an example: since I am gay, I can freely joke about homosexuality, unlike straight people.

I admit that I simply smiled and nodded, but inside I was like "wtf".

This idea seems strange to me. It would bother me if a straight person couldn't joke about gays. I mean, I can tell when someone just wants to joke or is acting in bad faith, so what's the point of this limit?

I don't see any sense in it and it seems a bit silly to me 😅 What do you think?