A. Peter McGraw and Caleb Warren wrote a research article, "Benign Violations: Making Immoral
Behavior Funny," in which they outline Benign Violation Theory as the foundation to study humor. The authors argue, "humor is aroused by benign violations. The benign-violation hypothesis suggests that three conditions are jointly necessary and sufficient for eliciting humor: A situation must be appraised as a violation, a situation must be appraised as benign, and these two appraisals must occur simultaneously." In other words, as the three conditions are met, we have a fertile environment for laughter. And humor, they conclude, "provides a healthy and socially beneficial way to react to hypothetical threats, remote concerns, minor setbacks, social faux pas, cultural misunderstandings, and other benign violations people encounter on a regular basis. Humor also serves a valuable communicative function: Laughter and amusement signal to the world that a violation is indeed okay."
Note the resonance here to Socrates' description of comedy as a mix of pleasure and pain (in Plato's Philebus), Aristotle's account as an imitation of the ugly or base (ludicrous), and Bergon's idea that humor serves as society's corrective response to the absentminded.