This scene occurs after Claudius has seen the play which essentially reenacts his murder of his brother, Hamlet’s father. Claudius is trying to pray, acknowledging his crime before God, but not asking for forgiveness. He says he cannot ask for forgiveness:
'Forgive me my foul murder'?
That cannot be; since I am still possess'd
Of those effects for which I did the murder,
My crown, mine own ambition and my queen.
Since he is still in possession of those things which he gained by the murder, he is unwilling to actually ask for forgiveness.
When Hamlet walks onstage, he is unseen by Claudius, who is still kneeling. Hamlet doesn’t hear him and does not know that Claudius is conflicted. To Hamlet, the sight of Claudius praying means that if he kills Claudius now, Claudius will be absolved of his crime and go to heaven. The idea of Claudius going to heaven is unthinkable for Hamlet:
A villain kills my father; and for that,
I, his sole son, do this same villain send
The above passage reveals the bitter irony Hamlet feels at the thought of sending his father’s killer to heaven. So he resolves to kill Claudius some other time:
When he is drunk asleep, or in his rage,
Or in the incestuous pleasure of his bed;
At gaming, swearing, or about some act
That has no relish of salvation in't;
A further irony in the situation is that Hamlet does not realize that Claudius has not asked for forgiveness. Perhaps if he had known this, he might have carried out his revenge.
Although Hamlet sounds earnest in this scene, we must keep in mind that Shakespeare doesn’t always spell things out directly for his reader. Is it really reasonable to presume that it matters when Hamlet kills Claudius? That implies that Hamlet, rather than God, has control over whether or not Claudius goes to heaven. Looking at it this way, it is easy to think that Hamlet may be rationalizing, just looking for a reason not to do it.