The scene also serves as some comic relief from the tension of the end of Act 4 when Claudius and Laertes lay out their diabolical plot against Hamlet and then find out about Ophelia's strange death. The gravediggers are telling jokes and using puns about Ophelia's death, death in general, corpses, and other otherwise morbid topics and in a scene of dark humor still reinforcing the themes that have been previously established in the play.
In Act V, scene 1, Hamlet confronts the physical consequences of death, having already considered the spiritual consequences elsewhere in the play. Indeed, he already made several references to morbidity, both in reference to Polonius and to the king. He also confronts the consequences of Ophelia's death, embracing her corpse. It is, in many ways, a foreshadowing of what is to come, and there is an eerie sense that Hamlet knows it.