Well first, as with any Shakespearean play, the inclusion of another level of society shows us how the play's themes resonate through all of the society. These aren't just the concerns of the few; these themes concern everyone. That said, the scene in the graveyard serves as a kind of ironic correction to Hamlet's waffling. He is so indecisive—and life is so short! He wants so badly to do the right thing—but all paths lead to the grave in time. He works so hard to put on a false face for those who he might deceive—but Yorick's face is completely gone, as all deception will be.