Yes. The lines "Who would fardels bear, / To grunt and sweat under a weary life, / But that the dread of something after death..." are from Hamlet's soliloquy, Act 3, Scene 1.
This passage encapsulates the soliloquy's core: enduring life's suffering vs. the terror of death's uncertainty.