Hamlet opens this famous soliloquy with the question of whether it is harder to live a difficult life filled with sorrow and angst or to die and face the unknown territory of death. He goes on to ponder death and the questions that it raises. He wonders what happens after one dies, what awaits each of us. He says this uncertainty and the essential fear of the unknown makes people fear death and thus fear actions that may result in death. He says that if we knew for certain what would happen to us after death, then would people put up with all the grief that life offers? He spells out some of these griefs, such as insults from people, abuse, unrequited love, etc. The main philosophical question is the first - is it harder to live in a harsh world or to die.
Hamlet questions the relationship between thinking and being. He presages the modern existentialism of Heidegger, who wrote Being and Time, and Sartre, who wrote Being and Nothingness. In his own time, Shakespeare draws on Descartes's "Cogito, Ergo Sum" ("I think, therefore I am"), and on philosophy of universal doubt. Descartes says:
“thinking ensures the fact of his existence, and, further, the existence of God, who will, in turn, ensure the existence of the Universe”
According to Kállay, Géza in “‘To be or not to be’ and ‘Cogito, ergo sum’: Thinking and Being in Shakespeare’s Hamlet Against a Cartesian Background.” AnaChronist [no vol. #] (1996): 98-123:
Hamlet uses thinking not so much to settle the question of ‘what exists and what does not,’ but to give its extent, to mark out its ‘bourn,’ the frontier dividing being and non-being, only to see one always in terms of the other. The major reason for Descartes’ and Hamlet’s different approaches is, of course, that in Hamlet’s world there is no final and absolute guarantee: in Shakespeare’s Hamlet God seems to interfere neither with thinking, nor with being (120).
So, if you break down the language it goes like this:
To be [alive] or not to be [alive].
Compare that to other famous lines of antithesis:
Descartes: "I think, therefore, I am [me]."
Yahweh: "I am that I am." or [I am that which I say I am].
Iago: "I am not what I am." [I am not what I appear to be].
Popeye: "I yam what I yam." [I am the person I am].
This is all nominalism; more specifically, it is known as the "be" mechanism. According to Wikipedia, "Nominalism is a metaphysical view in philosophy according to which general or abstract terms and exist, while or, which are sometimes thought to correspond to these terms, do not exist. In other words, according to Jud Evans:
Here the underlying predication expressed by the would-be suicide [which every reader instinctively understands] is: "To be [alive] or not to be [alive.]"