The soliloquy “To be, or not to be: that is the question” appears in Act 3 Scene 1 in William Shakespeare’s Hamlet. It is, perhaps, one of the best-known soliloquies by Hamlet in the play, which generates profound literary interest even today. Hamlet is feeling deep pain and sorrow because of his father’s death. It seems that he is unable to accept this separation. He doesn’t want to live. Contemplating suicide, he questions himself philosophically if it is justified to live with so much pain and agony or if ending his own life is the best possible option. So this soliloquy presents to the audience Hamlet’s dilemma of should he live or should he just die. In the next few lines of the soliloquy, he considers the fact that since suicide is a sin, it is not a noble thought. Such an unrighteous act will lead to eternal damnation. So, of course, Hamlet doesn’t commit suicide.
Hamlet is not contemplating suicide. Let's look at his situation. He has just met a group of players who intend to put on a play that very next night. He has formulated a plan that involves these players showing through their performance a scene similar to the one of his uncle killing King Hamlet. Upon witnessing this scene, Hamlet expects Claudius to unkennel his guilt. Hamlet will then have caught the conscience of the king. But what does that do for him. Catching the rat by the tail does nothing but draw the attention of the rat.
Hamlet's thought process is an examination or a rethinking of making the leap from resolution to action. One can go through life and quietly suffer the travails life brings or one can actively engage those troubles: a series of endless battles that only end when they end you. With action comes the spectre of death. And this is where people get hung up on the suicide thing, if death is the only thing that stops these slings and arrows why don't more people just end their lives? Human life is frail enough that it would take no more than a bare bodkin to surrender it. But, then there is the undiscovered country that causes one to consider that action as well.
Hamlet's mood is contemplative and studied. Does he take that big step and put his own life at risk or does he continue to quietly suffer. This soliloquy is magnified in Hamlet's final soliloquy in 4.4, where Hamlet watches Prince Fortinbras risk his own life in battle for the mere honor of leading men into battle. It is a specific example of what to this point has been kept general and abstract. Please note that the 2B soliloquy is spoken in the third person and no where in the soliloquy does Hamlet refer to himself. His inquiry is generic; part of his search for universals and though it is easy to place his particular circumstances within this dichotomy, it certainly does not lend itself to the conclusion that Hamlet is searching for a way out of life.
I feel I am right. In this soliloquy, Hamlet is questioning himself as in whether to continue to exist (and bear all the pain and sadness), or simply kill himself (and end all the suffering). No doubt he is avenging his father's murder, but the dilemma is whether to live or die.
I just found the same question answered by some other educators. Please go through them.