Immediately after 9/11, comedy ground to a halt. The Daily Show went off the air for nine days. Saturday Night Live, whose 27th season started 18 days later, featured a somber cold-open with Lorne Michaels asking New York mayor Rudy Giuliani, “Can we be funny?”

The staffers of The Onion, the satirical paper that had just relocated to New York, weren’t sure how to answer that question. Even three weeks after the attack, the comedian Gilbert Gottfried was publicly hissed at for joking that he was taking a flight that would make a stop at the Empire State Building.

…

The Onion’s triumph reflects McGraw’s long-held theory that comedy is equal parts darkness and light. The best jokes, he believes, take something awful and make it silly. Go purely light-hearted and you risk being toothless. Too edgy, and like Gottfried, you’ll make people uncomfortable.

This “benign violation” theory of humor is central to The Humor Code, which Warner and McGraw, a professor at the University of Colorado at Boulder, researched by digging into comedy trends around the world. The book comes out on April 1 (obviously).

McGraw’s thinking expands on the work of Stanford psychologist Thomas Veatch, which in turn builds on past explanations about why we laugh. Great thinkers have been trying for centuries to figure out the evolutionary purpose of comedy. The theories that have emerged are all very different, but one thing they share is a tendency to hint at the art form’s shadowy side.