Hamlet is debating whether he should take his own life or not.
Hamlet's Dilemma
To be, or not to be: that is the question.
Hardships In Life
He is contemplating about the troubles he has to face in his current lifetime.
Whether ’tis nobler in the mind to sufferThe slings and arrows of outrageous fortune,Or to take arms against a sea of troubles,And by opposing end them?
Death's Release
To die: to sleep; No more; and by a sleep to say we end the heart-ache.
Hamlet thinks about dying and how peaceful it would be to end the difficulties he is facing.
Sleep and Death
To sleep: perchance to dream.
Hamlet connects dreams and sleep, but he does not know if one can dream after death. It makes him aware that what happens after death is unknown,
The Unknown
But that the dread of something after death,The undiscover’d country from whose bournno traveller returns.
The fact that no one knows what is after death brings fear within Hamlet.
Resolution
Thus conscience does make cowards of us all.
He settles with his decision of living because his fear of the unknown is stronger than his desire for death.