What's so funny about spirituality? Humor is a way of letting go. It can help us drop the mask of ego. Not taking yourself so seriously (rule 62), or seeing beyond the ego, is the basis of all spiritual development.
Theories of Humor
Historically, three theories of humor have been discussed:
The Superiority Theory - that seeing the misfortune of someone else lets us feel superior and therefore, good.
The Release Theory - that some sort of energy or tension is released, making us feel good.
The Incongruity Theory - that exposure to an incongruity, somehow, makes us feel good.
Other theories have been developed, see Morrell who attributes humor to a pleasant psychological shift.
None of these attempt to explain laughter - the reflex producing the noise - that results from humor.
All of these theories have problems with some sorts of jokes or other humorous situations.
(author of the Dilbert comic strip and numerous books related to it and someone who knows a thing or two about humor) has a process for the engineering of humor that he lays out in the second half of " ". His "two of six" rule says that "all humor uses at least two of these six dimensions:
Six Dimensions of Humor
He then goes on to explain each of the six dimensions - giving some very funny examples along the way.
This small book by Jim Holt covers the three traditional theories and also includes a few actual jokes! He describes the history and philosophy of humor and the limits of the three theories.
Another possible theory of humor is that it is a communication system left over from the days when humans were more primitive. It is well known that some primates have different calls for different types of danger (one for "eagle" another or "snake" etc). Is it possible that pre-humans had a call for "it's ok" or "I'm just playing" and that call is still with us in the form of laughter?
The three traditional theories (superiority, incongruity and relief) attempt to categorize humor, they do not explain laughter - the sound, the reflex. The communication theory does.
If we see someone slip and fall but are pretty sure he's not really hurt, we may laugh. We may even laugh at ourselves if we trip and fall but are not hurt. The relief felt - than God I'm ok - in of course pleasant and the happy message is communicated via laughter. The relief theory says we feel relieved, but not why we want to make noise about it.
Another possible meaning of the primitive call we know as laughter would be to say "this is only play". For example, if someone sneaks up behind you, grabs you around the waist and attempts to wrestle you to the ground, you are going to have a very different reaction if he is giggling the whole time. you won't "fight for your life" potentially injuring someone who is probably a friend.
Social animals will need play as a way both to educate the young in the ways of hunting and self-defense and for ranking individuals with the group. A build-in indicator that what is going on here is play and not a real fight would be very useful or even necessary. Also, since the group needs play, the best way to ensure that it happens is to make it pleasurable to the individual engaged in it.
If this theory of laughter is correct, it suggests a theory of joke construction. There has to be an element of danger or uncertainty. It can be social danger (that's why dirty jokes are such a big sector). Other sources of social danger are the taboos of polite conversation: God, religion, politics, death, old age. So a joke will appear to be heading straight for a dangerous topic "who was that lady I saw you with last night?" and then introduce a surprise turn that quickly relives the situation "that was no lady, that was my wife"/ Note that the surprise by itself is just a surprise - without the set up it's not going to be funny. Also note that the surprise is generally necessary. If the audience figures out where you're going before you get the words out - it's probably not so funny. This is because the higher brain functions have a chance to step in and suppress the primitive communications - laughter.
This is also the theory of as described in Wikipedia.
And a good article at: Laughter as Therapy.
Any class clown will tell you that it's easiest to get a laugh just before a big test. If people are nervous, why should the be ready to laugh? This may be a situation close to what Freud was thinking of - a lot of "energy" looking for a release. People in a tense situation are ready to laugh because the really need a relief and, after all, a math test is not the kind of life and death situation that would justify the kind of tension it sometimes evokes. Thus the communication that "It's safe, It's safe, It's safe".