One of the ways that we learn is "do X -> reward" and "don't do X -> no reward". But this is only training us one way - a positive way - about what is desirable.
How do you learn what is not desirable. "Don't touch the oven when its on" is something that you learn through "do Y -> punishment" ... but is there a "don't do Y -> reward" path that can be found? Is there a way to positively train the "don't do Y" paths?
A mother says to her son "don't forget to sweep the corners." The son replies "don't worry, I swept everything into the corner."
You are rewarded for laughing at that joke. Why? Because it is something that you shouldn't do. In this joke, we have expressed an undesirable state to be able to learn from in a rewarding way rather than a punishing way.And somewhere, long ago, I recall a web page that had a short summary of each theory of humor and a joke that was not funny according to that theory. I doubt there will ever be a Grand Unified Theory of Humor.