When William Shakespeare put this in his play Hamlet he was, of course, quoting Thomas Aquinas Summa Theologica Volume 2. Hamlet asks the skull of a man who has ceased to be whether it is better to live or die?
In the original reference Aquinas states that every contingent thing has in it something necessary. Contingency arises from matter. Things made of matter have in them the potentiality to be or not to be.
Shakespeare was quoting the following reference:
Summa Theologica Volume 2: Treatise on man: What our intellect knows in material things: Whether our intellect can know contingent things?
REALISM
The principle of identity – in the order of being (ontology) Aquinas states that everything is identical with itself. This signifies the unity of things. Ontologically something must either be or not be; it cannot both be and not be at the same time and in the same sense.
Most people find ontology difficult to follow, but they get the bit about the dialogue with the skull. They get that life is a difficult and painful business. Maybe we sometimes wish not to be.