In examining the elements of the scene, there is the case of Yorick. As Hamlet contemplates his skull, he was revolted, "My gorge rises at it." It was a base and grim picture brought together with how he was reminded of the poor dead man. Shakespeare did not only created Yorick as a virile human specimen, he went further by making him a jester, underscoring the best that life has to offer. In Hamlet’s memory, he was characterized as "a fellow of infinite jest, of most excellent fancy." It was tragic, hence, how they ended with the skull and all it represented.
Shakespeare is warning his audience that worldly things that we are preoccupied with - family, wealth, beauty, among others - may be inconsequential. Yorick and, with the impedning funeral, the king were examples of how life would inevitably end up. The suggestion was made more potent by the presence of the gravedigger. With him and what he had to say, the audience is reminded that in the grave, all becomes equal.