This is probably the most famous infinitive in the English language. For, to be is the statement of existence. The famous line quoted above is from Hamlet's fourth soliloquy in Shakespeare's play. In The Birth of Tragedy (1873), Nietzsche saw Hamlet not as the man who thinks too much but rather as the man who thinks too well.
In his soliloquy, Hamlet, ponders the present, but the personal experiences of the past immerse themselves into the present as well. Here Hamlet has the existential experience of all of life as he looks into the essence of things. While questioning if he should try to set right what life has put out of order, Hamlet is almost nauseated. Thus, in his malaise, he wonders if it would be better not to be alive in such disorder:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them. To die, to sleep--
No more; and by a slepp to say we end
The heartache, and the thousand natural shocks...(3.1.56-62)
Hamlet's question is metaphysical, but it questions deeply the very concept of existence.
The 2B speech addresses two concepts. First, whether life is worth having and second the impediments of turning resolve (resolution) into action. The second concept naturally flows from the first because Hamlet realizes that though we just "can be" without doing anything, we can't simply "not be". Hamlet's exploration of "not being" involves 2 ways to "not be". The first is taking arms against a sea of troubles. The second is making your own quietus with a bare bodkin. "Not being" requires some forward action beyond the mere resolution to do so. This is the second part of his soliloquy: turning resolution into any action is generalized from the specific example of doing something to "not be".
In light of life's burdens is life worth having or not. As nobility Hamlet has had his preconceived notions of what it is to be noble. The chink in the armor is his realization that nobility is not a state of mind bestowed at birth rather it must be acquired. The ultimate conclusion he draws by the end of the soliloquy is that if one settles on being noble of mind and nothing more then he is a coward -- a paradox, hardly keeping with nobility. We see this expanded in Hamlet's last soliloquy in 4.4. "How all occasions do inform against me..." where Hamlet watches Prince Fortinbras resolve to act for an "eggshell". Again the dichotomy of passive forbearance versus the nobility of action.