In Act 5, scene i, when the clowns open the scene, they are discussing with one another the woman who is to be buried in the grave they are digging. The first clown is wondering if she will receive a Christian burial since she killed herself..."she willfully seeks her own salvation". The second clown says she is to have a Christian burial, so the grave must be dug well and not haphazardly. The coroner has "sat on her, and finds it a Christian burial".
The first clown declares in his banter that she drowned herself willingly, therefore, no matter who she is, she should not have a Christian burial since suicide is the greatest sin. The second clown declares that it was probably an accident, otherwise the coroner would not have judged it a Christian burial.
They go on about the law, but the second clown comes around and says, "Will you have the truth on it? If this had not been a gentlewoman, she should have been buried out o'Christian burial."
They then begin to banter about whether or not Adam was a gentleman, if he had arms or not in order to dig with, and the final riddle, "What is he that builds stronger than either the mason, the shipwright, or the carpenter?" The answer given was a "gallows maker," but the answer sought is a "grave maker" since the house he "makes" lasts forever.
This is when Hamlet enters, as the first clown sings a song and begins digging the grave of Ophelia.
Their purpose in the play is to lighten the mood a bit after Ophelia's death and before Hamlet realizes it is Ophelia's grave they are digging. Comic scenes such as this one are dropped in to relieve the tension and allow a little laughter in the midst of sorrow and death.