In Scene III, Hamlet enters as the King kneels to pray. What do we learn of Hamlet's character from his soliloquy?
One of the other things about the scene that is important is the contrast, in Hamlet's mind, of the circumstances that Claudius is in compared to those that his father was in when he was murdered. His father went to his death still encumbered by all his sins, unable to make a final reckoning and so is stuck in purgatory, a place he says he cannot tell Hamlet about because it is so terrible.
So we see that Hamlet weighs the possibilities while considering killing Claudius and feels that it would be crazy to kill him and send him to heaven instead of to hell where he belongs.
It confirms what we already have seen about Hamlet having pretty serious feelings about the religious philosophy common for the time.
The speech you mention is in Act III, Scene 3. It is the one in which he thinks first that he will kill Claudius, but then decides not to.
First, this speech tells us that Hamlet believes in the religious ideas of his day. He thinks that there is a heaven that is a good place. He thinks that Claudius will go there if he dies while playing.
Second, it shows us that Hamlet is a very vengeful person. He hates Claudius so much that it would not be enough to just kill him. Instead, he wants to kill him at a time when Claudius will die in sin and will go to hell. This is pretty harsh -- he wants Claudius to suffer in hell for all eternity.