Comic relief usually occurs in tragedies.
Tragedies are dramatic plays that typically depict serious and often fatal events, such as the downfall of a tragic hero or a devastating disaster. To alleviate the tension and provide a momentary break from the intense emotions, playwrights may insert humorous scenes or characters. This is called comic relief.
For example, in Shakespeare's tragedy "Hamlet," the gravediggers scene provides a moment of comic relief as they engage in witty banter while digging graves. Another example is the character of the Porter in "Macbeth," who provides a humorous monologue that lightens the mood after the dark and intense murder of King Duncan.