These famous words occur just before Hamlet confronts Ophelia. He is debating with himself over what he should do. Should he go through with his plan to avenge his father's death, or should he just give up and kill himself? He then wonders of there is an after-life and what it is like. He contemplates whether he should suffer now or suffer later.
What does this tell us about Hamlet? He is a man of thought and words, not actions. He's philosophical about life and death. He spends time analyzing his situation and himself rather than acting right away. Hamlet also suffers from depression, so when he is asked by the Ghost to act, he really isn't prepared to do so. These words show Hamlet's true nature and how he is haunted (pun intended) by the conflict of acting to avenge his father or giving up and committing suicide. This scene shows the full extent of Hamlet's pain and suffering. In the end, Hamlet does act after he has undergone a great change in his character. He becomes a " 'new' self-defined Hamlet. . . reading for action."
This speech adds to our understanding of Hamlet in several definite ways, and in one more hypothetical way.
Start with the basics: It lets us know how upset Hamlet is. He just stops in the middle of a quest for his father's killer and talks to himself.
What does he talk about? Whether to kill himself or not. That's how upset he is, and how dark his mood is.
What does he say? That's the next thing the speech tells us. He decides that life is so hard that people (at least he) would be likely to kill themselves if they weren't afraid that what comes after life was going to be worse than what came during. Since his dad is murdered and he's suicidal, that's a pretty bleak picture of the afterlife.
We also learn lesser things, like he's educated, and that he can think logically even when upset, but those are minor.
The hypothetical thing? Does he know Ophelia is listening? How much of this is him showing that he's upset for her benefit?