Hamlet is one of William Shakespeare's most popular plays. The title character, Hamlet, has many soliloquies throughout the play. Almost all of the soliloquies by Hamlet are philosophical in nature. The soliloquies act as expressions of Hamlet's innermost psyche, allowing the audience or readers to literally read his mind.
The soliloquy is also a literary technique that allows Shakespeare to express his philosophical ideas and theories on the human condition. A character, after all, can sometimes be essentially a proxy or avatar for the author; in this regard, Hamlet might be considered a literary manifestation of Shakespeare himself.
A majority of Hamlet's soliloquies hint at signs of manic depression. In the second scene of act I, Hamlet contemplates suicide, but his religious values eventually dissuade him from acting upon his flirtations with death. This technique—an author expressing their own thoughts and feelings through characters in their literary work—has become popular among writers, filmmakers, and playwrights since Shakespeare's time.
Hamlet is one of the earliest examples of an English-language work to use a stream of consciousness–style monologue. Today, this form of writing has become popular among writers (e.g., confessional blogging).
The soliloquies also add dimensions to the characters in the play. When Hamlet comments about himself or on other characters, we get an in-depth look into those characters' true nature (or at least their nature from the perspective of Hamlet). Therefore, soliloquies help with smoothing the narrative flow of the acts.