What function do the gravediggers have at the beginning of act V?
The gravediggers serve to progress the themes of death and birth and youth and old age. They set the mood for the end of the play that will result in multiple murders. Just as Act I began with the Ghost, Act V begins with the graveyard scene, showing that death and decay will be man's end.
The gravediggers believe Ophelia killed herself and would therefore not be entitled to a Christian burial, but the coroner has said she can be buried with Christian rites. The gravediggers say Ophelia is being given special consideration because she's a member of the gentility. One of them sings about how his youth is gone, and he is now victim to "age with his stealing steps," which "hath shipped me into the land,/As if I had never been such." He also reveals he's been digging graves since Hamlet's birth, emphasizing birth and death in life.
Hamlet and Horatio enter the graveyard and notice the skulls the diggers have unearthed. Hamlet's remarks to Horatio suggest that man's natural end is death and decay. Their conversation of mixing personal stories with political views highlights the revenge theme shown throughout the play and the consequences of revenge.
The clown diggers serve a few purposes. In general, clown gravediggers can demonstrate the meaningless and worthlessness of death, for digging graves is so common for these men that they don't feel sad or frightened when they do their job. This allows us to realize that everyone's death is the same—no big deal in the vast scheme of things—no matter how great that person was when alive. However, in this scene the two clown grave diggers also heighten the tragic grief of Hamlet, Laertes, and Gertrude as they suffer the needless death of Ophelia. In this way, Shakespeare at once provides a sense that we are all equal when we die in that we turn to dust, but on the other calls attention to how important one human being can be to another, so that the loss of a loved one results in enormous grief and suffering.