In Act III, Scene i, Hamlet gives his most famous soliloquy, “To be or not to be, that is the question!”
He is contemplating whether or not to kill himself. He asks himself what would be more noble, to suffer the pain of life or to fight against the pain. If he kills himself, will he not find rest (sleep)? Will it not just be like falling asleep? Surely if he kills himself, his heartaches will be over, won’t they? Oh, but then there are dreams. What if he kills himself, and finds sleep, but in that sleep, he has nightmares? Nightmares are a part of sleep, are they not? “There’s the catch!” Maybe it’s not so simple. The nightmares might be so bad..............and this thought makes him think he should not kill himself:
“For what dreams may come in that sleep of death, when we have left this life on earth, must make us stop.”
He concludes that the act of suicide is a sin and the “dread of something after death” – the fear of what lies next – makes a man pause and think that perhaps it is better to put up with life’s sorrows and die when it is time, not to hasten one’s death “with a bare, sharp knife.” Perhaps by killing himself, he will bring on worse sorrows. He concludes, “In this way, a conscience can make cowards of us all.”
You can read the text of his speech here on enotes in a modern translation.