From which play or poem does the famous Shakespeare line 'To be or not to be' originate?

Hamlet, written by William Shakespeare around 1600, is a cornerstone of English literature and arguably his most famous tragedy. The play explores themes of revenge, morality, and madness, all centered around Prince Hamlet of Denmark. The "To be or not to be" soliloquy is delivered by Hamlet in Act 3, Scene 1. In this speech, he contemplates suicide and the nature of existence, weighing the pain and suffering of life against the uncertainty of what comes after death. The line encapsulates the internal conflict that defines Hamlet's character. While Shakespeare's other plays like *Henry V*, *Romeo and Juliet*, and *As You Like It* are also well-known and beloved, none of them contain this iconic phrase. *Romeo and Juliet* is a tragedy focused on romantic love, *Henry V* is a historical play about kingship and war, and *As You Like It* is a comedy exploring love and identity in a pastoral setting. The philosophical depth and introspective nature of "To be or not to be" are unique to *Hamlet*.
The eternal question 'To be or not to be' was first asked by the Prince of Denmark, Hamlet.