In Hamlet, what is the function and significance of Hamlet's soliloquy "To be or not to be"?
This soliloquy placed just after Hamlet's soliloquy in Act 2 when he devises a plan to "catch the conscience of a king." It is interesting that it is placed at the beginning of Act 3 just before we see Hamlet and Ophelia on stage together for the first time, a scene in which Ophelia is acting as bait while her father and Claudius spy on Hamlet. It is a beautifully meditative speech debating the pros and cons of living in this world when suicide would take one out of this "sea of troubles" into a world of sleep.
It is clear from this soliloquy that Hamlet is not mad. He is melancholy about life, but not necessarily suicidal. The soliloquy is not in first person. At the end of the soliloquy, Hamlet reasons that because we fear the unknown in the afterlife, we will continue to live in a world that causes pain and suffering.
It is important that we see Hamlet here as thoughtful, logical, and perceptive. In contrast, we can see his actions toward Ophelia as more of an act put on for the benefit of the two spies Claudius and Polonius, whose presence Hamlet most surely has detected.
But the "To be or not to be" soliloquy also shows Hamlet's dread of killing. He is most reluctant to take revenge and he most likely fears the confirmation of the ghost's words that is sure to occur when the play that Hamlet has requested is performed. Life to Hamlet seems overwhelming just now, and suicide is an appealing idea. Death seems more appealing than seeking revenge.
But Hamlet is not suicidal. He sees the path ahead that he must go down, however reluctantly, and after the play-within-a-play, he seeks the revenge his father's spirit requested. Of course, his attempt at revenge fails when he kills Polonius instead of Claudius, and the play takes another turn.
The most important part of this soliloquy is near the end. As the other posts have mentioned, Hamlet is very rational in this speech. He has been a very contemplative character through the whole play, but here he specifically talks about that.
Through the speech he is taking about action and inaction, and in the end he concludes that the reason people don't act is because they fear the consequences of their actions once they start to to think about them. He asks what "makes us rather bear those ills we have" (not act against them) rather than "fly to others we know not of." The next several lines are his rather profound, and very true, conclusion. He suggests: "Thus conscience makes cowards of us all, / and thus the native hue of resolution / is sicklied o're with the pale cast of thought." He is saying that thinking, or over-thinking, makes us fearful and cautious, and once we feel that way, then our drive to act is taken over by our thoughts and intellect.
This speech is clearly Hamlet showing us an understanding of himself and his lack of action up to this point in the play. He does take action eventually, but this is not the last time that Hamlet's drive to act to overcome by his overthinking things -- consider his decision to not kill Claudius a little later in Act 3!
We have heard Halmet on stage several times by this point in the play. Instead of being overtaken by extreme emotion, this moment positions Halmet as a rational thinker. In considering the consequences of the different answers to the question he is actually asking, his thoughts are genuine and well-thought out. In considering death and the unknown Hamlet compares it to what he can understand in the concept of sleep. In considering still living, he weighs all of the problems and struggles he endures right now. He is measuring the difference in the values of the two. This may be demonstrating a growth and maturity in Hamlet that we have yet to see until this point. In my opinion, this is what makes this soliloquy significant.
Also, when complete, Hamlet asks Ophelia for her prayers for him. This demonstrates the acknowledgement that he understands he cannot humanly cope with his circumstances on his own.