Humor can be either very dependent on an escapist mindset or the very opposite. Laughter is a diversion, much like fantasy, though it also often requires an understanding of what is actually going on. For instance, for slapstick and other comedy involving bodily harm, the awareness that the pain is fake makes it funny rather than tragic.
RELATED
Jerry Seinfeld explains how to write a joke.
How To Be Funny: The Six Essential Ingredients To Humor from Bakadesuyo
What are we allowed to laugh at? by Ben Pobije
Andy Borowitz’s list of ’50 Funniest’ writers.