The gravedigger scene is designed to give comic relief, after what has been a very dramatic ending to Act IV. The sadness of the death of Ophelia is compounded by Laertes' rage at Hamlet's killing of his father. The gravedigger also gives many truths about life such as that death is the end, Ophelia may have killed herself and therefore should not be buried in sanctified ground, and that at the end we all end up the same way. Obviously, since this is a tragedy, it cannot end as merrily as it begins. The audience just needs a chance to breathe before the intensity of the final sword battle and the death of all the main characters takes place.