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?