This comes from Hamlet's soliloquy in Act ? Scene ?. he is contemplating suicide and questioning what comes after his death. He's saying that if he dies he is just sleeping and maybe he will dream i.e. go to heaven. Sleeping shows that he views death as an escape and will help him to rest his soul. "rest in peace"