In Hamlet, what does "To be or not to be" mean?
In Hamlet, the "to be or not to be" is not about suicide. Hamlet would not be debating suicide here. He had debated it earlier, but the Ghost has presented him with purpose now: kill the king and send him to hell, thereby freeing the Ghost from Purgatory to heaven. If Hamlet suicides, both he and the Ghost will go to hell, and, worse, Claudius might go to heaven.
Rather, the monologue is a meditation on existence (the interrelated nature and meaning of life, suffering, and death). According to existential critic Rheinhardt Grossman in Phenomenology and Existentialism:
Two things keep Hamlet from committing a suicide: fear of death and uncertainty that waits for him after it and the wish to revenge for his father’s death. Vainness and confusion are two words which can characterize all his life. Even when he decides to revenge for his father’s death and kill Claudius he does not use his chance. He got lost in his eternal thoughts about useless life, sufferings and pain. He is not able to see the world in a new perspective and cannot get out from the web of fear, darkness and pain which he himself created.
The monologue is about activity vs. passivity in response to suffering and a society gone to pieces: "to be (active) or not to be (active)" or, conversely, "to be (passive) or not to be (passive)." Hamlet wonders if he can withstand all of misery that seems inherent in the human condition. Is there a point to suffering? Should he fight against it or just accept it as inevitable. Denmark is a prison: is there a point in fighting to escape it when the world outside its walls might be a prison as well? To him, the world is so corrupt, that life seems pointless. Should he give up hope?
The soliloquy might also be interpreted in terms of the after-life. It's about being damned to hell by committing revenge or not being damned. So, "to be (damned) or not to be (damned)." The problem of sending the Ghost to heaven and Claudius to hell will cause him to go to hell as well (murderers go there).
In the end, though, Hamlet resolves his spiritual crisis by giving this answer in response to his earlier monologue:
If it be now, 'tis not to
come, if it be not to come, it will be now; if it be not now,
yet it will come. The readiness is all. Since no man has aught of what he leaves, what is't to leave betimes? Let be."
Hamlet has readied himself for activity and for the afterlife in Act V. He has thus answered his own earlier questions.
Hamlet's meditation in this soliloquy consists of a philosophical argument: why do men endure suffering when they have the means to take action and relieve their suffering by dying. In some ways this soliloquy is about suicide, but Hamlet it not contemplating his own suicide but that of people in general. He carefully weighs the pros and cons of living, with the cons vastly outweighing the pros:
Who would bear the whips and scorns of time,
The oppressor's wrong, the proud man's contumely,
The pangs of disprized love, the law's delay,
The insolence of office . . . .
When he himself might his quietus make
With a bare bodkin?
The fact that Hamlet does not use first person pronouns here is important. He is not suicidal here. He is only thinking. Of course, he comes up with an answer: Man is afraid of the afterlife ("What dreams may come"); therefore he clings to the "calamity of so long life."
This soliloquy seems somewhat out of place. At the end of Act 2, Hamlet had just come up with a plan to determine Claudius' guilt. But at the beginning of Act 3, we see him contemplating life's sufferings and the temptations that we all have to end them. Perhaps Hamlet is afraid of what he will find out about Claudius, that he will learn that Claudius is indeed guilty, and that he will be forced to take revenge--an action that Hamlet would rather not take. At this point, Hamlet may very well appreciate the temptation that we all have to avoid suffering through death. It is part of the human condition to ponder such ideas even though most of us do not act on them.
Basically, Hamlet is trying to decide whether he wants to live or die.
He thinks that living is pretty pointless. He is very unhappy because of the horrible things that fortune seems to throw at him. Because of that, he would rather be dead.
But then he thinks about death and he thinks about how death is the "undiscovered country." He thinks about how nobody knows what happens next. What if it is worse than life? So he decides to stay alive. He says that the decision is based on the fear of the unknown.
Many people believe that Hamlet is debating suicide here. If Hamlet truly wanted to die, Claudius would gladly oblige. Instead, Hamlet takes great care in keeping his activities secret from Claudius. Should Claudius find out his true intentions, he would indeed take pains to make sure Hamlet got his "death" wish, as he does attempt to do when he sends Hamlet to England. If you study the early part of the play, especially Hamlet's monologues, you will find that Hamlet's greatest dilemma is indecision. He cannot bring himself to act without caution, yet he feels like a coward for doing so. In this soliloquy, Hamlet is not debating whether he wants to continue living or not (not "be" in that sense), but to "act" or "not to act" is his question.