Laughter would be the body's mechanism for successfully managing an input/output exception.
Jokes make us laugh because the punchline unexpectedly departs from the expected outcome of the narrative. Our brains try to anticipate what will happen and respond, but when the brain has been tricked, it has to reconcile what happened. We're rewarded not with a core dump, but a feeling of pleasure.
If it wasn't pleasurable to be surprised, we'd have an existential crisis: Our brain failed to anticipate the correct outcome. Now we have to figure out if our senses are wrong or if there is a new phenomena to understand. The natural reaction would probably be fear and flight.
That isn't the kind of behavior that moves the species forward- risk taking and information gathering only endure if you are able to manage ambiguity. Successful humans found pleasure in the unexpected. Laughter seems to be a core component of our survival skill. Laughter also seems to be a common symptom of schizophrenia. Maybe laughter is just the result of the brain's garbage collector firing.