What does William Shakespeare mean when he says "to be or not to be" in Hamlet?
In Act 3, Scene 1 of Hamlet, the main character utters what would become one of the most common allusions in all of literature: "to be or not to be." This line is written by Shakespeare, but spoken by the character of Hamlet. "To be or not to be" hinges around the verb "to be," in other words "to exist." Once you put the line into that context, a reader can easily see what Hamlet is pondering: to exist or not to exist. Most scholars agree that Hamlet is considering whether or not to commit suicide. At this point in the play, Hamlet is completely distressed that his uncle killed Hamlet's father and then married Hamlet's mother. This entire soliloquy involves Hamlet pondering the question of suicide and then giving reasons as to why he should kill himself. Of course, Hamlet does not go through with suicide. He later reasons that "conscience does make cowards of us all." Here Hamlet admits that, due to the fear of hell, Hamlet becomes a coward and cannot act. (Many consider inaction to be Hamlet's tragic flaw.) There is a great irony in that, while Hamlet contemplates suicide but fails to do so, Ophelia contemplates suicide and succeeds in doing so. According to Hamlet's theory, then, Ophelia is the character with more courage.
Hamlet is not pondering suicide he is pondering action. Having thought through his plan to catch the conscience of the king, Hamlet is faced with the consequences of his action to come. He can idly suffer at the hands of fortune or he take charge of his own destiny. Hamlet sets up quite a quandary: quietly suffering in one's own cowardice or actively battling one's ocean of troubles. As Harold Jenkins in the Arden Hamlet points out, taking arms against a sea of troubles does not end one's troubles rather they ultimately end you.
Hamlet in this speech is speaking in the third person and generalizing the dilemma for all persons similarly situated. But what he is saying in light of his own situation is that if he goes through with his plan to catch the king, he places his own life on the line. This point is specifically expressed in his 4.4 soliloquy as he observes another prince do precisely that. It's no coincidence that as Hamlet departs for England he is in the same boat, so to speak, as Prince Fortinbras because Claudius intends to take Hamlet's life.
Hamlet isn't worrying about taking his own life, he is worrying about someone or something else taking his life in the active engagement of life's troubles. Turning resolution into action has consequences that Hamlet is not sure he is prepared to meet.
Hamlet's thoughts on suicide occur at two places in the play. The first is in his first soliloquy in Act 1 Scene 2 where he recognizes that "self-slaughter" is against God's commandment (i.e. Thou shall not kill). Here, Hamlet is being over dramatic: youthful hyperbole. His morose expressions establish his youth and an unrealistic view of death. His mood is sullen having suffered the tongue lashing from Claudius and Gertrude. Denied his studies, the crown, the alliance of his mother and the guidance of his father, Hamlet feels like he has no purpose. He says it is only the stain of sin that keeps him from killing himself. This all changes when his father's spirit challenges him.
Second at the end of the play as Hamlet lays dying, Horatio expresses the desire to follow Hamlet in death. Hamlet rejects Horatio's attempt. Like the Ghost's injunction to Hamlet, Horatio has a purpose. He wants Horatio to carry on Hamlet's memory and champion his good name. Remember me.
Much ink is spilled over the idea that Hamlet's soliloquy in 3.1 expresses suicidal ideation. This interpretation is misguided. Toward the end of his speech Hamlet does mention that life can be surrendered by a mere bodkin. Here, Hamlet is expressing the frailty of the human body and the ease with which life can be taken. The difficulty in taking a life does not lie in the body's resistance to harm; rather, it is the resistance of the will. This furthers the thought on the hesitation between resolution and action which is the theme of the soliloquy as a whole. Hamlet is not worrying about killing himself he is concerned about being killed at the hands of another. More generally (and Hamlet is frequently occupied in searching for universal principles) Hamlet realizes that taking arms against a sea of troubles, i.e., meeting the day-to-day travails of life's burdens, may ultimately shortens ones life.