Hamlet feels insignificant in his life, and is overwhelmed with the utter baseness of the death and decay he sees.
The scene opens with the clowns discussing whether or not Ophelia is entitled to be buried on consecrated ground (because she was a suicide she should have been relegated to a different section). This suggests that where our bodies lay matters. Yet the rest of the scene shows it does not, for even in consecrated ground, the bodies are disturbed and treated with irreverance.
Hamlet is disturbed by the clowns' light-heartedness as they sing and toss skulls about. He looks into the graves and thinks of the people the dead might have been--a lawyer, a politician, a land-owner, even a great leader. The clowns have unearthed the stinking skull of the jester, Yorrik (see Jamie's quote), who used to be full of life and humour, and he realizes that we come to nothing when we die. Our skulls could be tossed about by singing gravediggers. Even the bodies of great men like Alexander or Caesar would eventually turn to dust and then to dirt. He says Alexander might have turned to loam that could be used to stop a beer keg. As for Caesar, he might be used to stop up a hole to keep the draft out:
Imperious Caesar, dead and turn'd to clay,
Might stop a hole to keep the wind away:
O, that that earth, which kept the world in awe,
Should patch a wall to expel the winter flaw!
We have no protection against the indignities of death. Life will take it all and who we were won't matter.