Actually, the speech is not a soliloquy, and I don't believe it's about suicide. Ophelia is on stage and clearly means to be noticed by him. Hamlet may be delivering the monologue to her. It is debatable if suicide is truly contemplated; rather, it is a meditation on existence (the interrelated nature and meaning of life, suffering, and death). According to existential critic Rheinhardt Grossman in Phenomenology and Existentialism:
Two things keep Hamlet from committing a suicide: fear of death and uncertainty that waits for him after it and the wish to revenge for his father’s death. Vainness and confusion are two words which can characterize all his life. Even when he decides to revenge for his father’s death and kill Claudius he does not use his chance. He got lost in his eternal thoughts about useless life, sufferings and pain. He is not able to see the world in a new perspective and cannot get out from the web of fear, darkness and pain which he himself created.
After this, he advises Ophelia to get to the nunnery, which seems to be directed more at his mother than her. So, one wonders if any what Hamlet says in this scene is genuine or feigned madness. James Hirsh in “Shakespeare and the History of Soliloquies” says it is “feigned...spoken by Hamlet to mislead other characters about his state of mind.”
In addition, German philosopher Arthur Schopenhauer says:
The essential purport of the world-famous monologue in "Hamlet" is, in condensed form, that our state is so wretched that complete non-existence would be decidedly preferable to it. Now if suicide actually offered us this, so that the alternative "TO BE OR NOT TO BE" lay before us in the full sense of the words, it could be chosen unconditionally as a highly desirable termination ("a consummation devoutly to be wish'd" [Act III, Sc. I]). There is something in us, however, which tells us that this is not so, that this is not the end of things, that death is not an absolute annihilation, unless it's written upon another, for love is the ultimate end and will forever be remembered in our hearts. For he will be mine and remain mine for eternity.
Hamlet knows he cannot commit suicide; otherwise, both he and his father may very well go to hell (his father is stuck in Purgatory, remember). Clearly, Hamlet's decisions are framed from Christian theology, which states suicide is a cardinal sin that guarantees eternal damnation.
So, you must ask yourself, does Hamlet's speech (inadvertently) plant the seed for Ophelia to commit suicide later?
First, I suggest that Hamlet's famous "To be or not to be" speech in Shakespeare's Hamlet, is not primarily about suicide. I believe it is about existence itself: to be, is to exist. The central question in the speech is whether or not existence is worthwhile. Suicide only comes into play because it is a method of eliminating one's existence if one already does exist.
That said, there are numerous reasons, according to Hamlet, why one might not want to exist. It would make a long list. I'll quote part of it for you.
For who would bear the whips and scorns of time,
Th' oppressor's wrong, the proud man's contumely,
The pangs of despised love, the law's delay,
The insolence of office, the spurns
That patient merit of th' unworthy takes,
When he himself might his quietus make
With a bare bodkin?...
A few lines earlier, Hamlet speaks more generally:
The heartache, and the thousand natural shocks
That flesh is heir to.
These, too, are things that one could avoid if one didn't exist.
Hamlet's main argument against suicide is that no one knows what dreams may come with death. That's the "rub," as Hamlet refers to it.
The basic argument in this soliloquy goes something like this:
I should kill myself because I really hate life. Everything in life is hard, so why should I deal with it?
But on the other hand, I can't kill myself. I have no idea what happens after death. What if it's really bad? So I'm too afraid to kill myself and I think I will not do it.
Hamlet fills in some details -- life is bad because people make fun of you, people you love don't love you back, you have to wait for stuff. But the basic idea is that life is tough.