McGraw’s studies have led him to endorse something called the benign-violation theory, which holds that “humor only occurs when something seems wrong, unsettling, or threatening (i.e., a violation), but simultaneously seems okay, acceptable, or safe (i.e., benign.)” The form this takes in most jokes and comic situations is to begin with the threat of a violation of some sort and save the uneasiness this causes by its turning benign at its end.
Commentary Magazine dissects the gory insides of humor.