The most extensive piece of comic relief in Hamlet is in Act V Scene 1.
The scene begins with a discussion between two "clowns" who are digging a grave for Ophelia, who has committed suicide. The clowns engage in a convoluted discussion about whether a suicide victim should be granted a "Christian burial." Part of the humor is in the clowns' mispronunciation of legal terms: "se offendendo" for se-defenden-do [in self-defence], and "argal" for ergo [therefore].
The clowns continue by posing riddles to each other. The answers to the riddles are grave-digging and gallows maker.
Hamlet and Horatio arrive and engage the gravedigging clown in humorous conversation. As they are talking, the gravedigger unearths a skull which he says is that of Yorick, a man who had been court jester to Hamlet's father. This gives Hamlet opportunity to reflect on the nature of death. He realizes that all people, no matter how great, will return to dust and that their skulls will be useless except for "stopping a bung hole"--for plugging a wine barrel.
Although the scene is full of jokes, it deals with man's mortality. It is a perfect introduction to the play's next and final scene, in which Laertes, Gertrude, Claudius, and Hamlet all meet their deaths.