Humor is being led down a common path to a known destination and somehow cleverly transporting them to some other, unexpected place.
Three guys walk into a bar... a fourth ducks... bu dum tsss.
It's "funny" because it starts us down the known path:
Oh Yea... A Priest, a Pastor, and a Rabbi...[this is gonna take for-ever!...]
and startles us when we wind up somewhere completely different:
...a 4th guy ducked...
"Huh? Oh yea, haha!"
I love how you connect the discomfort of comedy. It is off-putting. It will always be a threat to cut a bit too close for people. And those people are completely random; people who are exposed by the raw nature of the comedy.
I think that's fascinating and an often unexplored aspect of comedy. Makes it not so strange that some of the funniest people on the planet are not very happy to down right miserable.
Peace~