In Shakespeare’s play, Hamlet wants to kill his uncle Claudius because a ghost of Hamlet’s father has told Hamlet that his own brother Claudius has killed him by pouring poison in the ear. Hamlet wants revenge from the new king Claudius because he has gotten whatever the old King Hamlet had.
Once Hamlet finally makes the decision to kill Claudius, he stops when he sees Claudius praying. Hamlet, knowing that his father may be in Purgatory, does not want to kill Claudius after he confessed of his sins, but rather when he is partying, drinking, having incestuous sex, or committing some sort of sin. As Hamlet believes him to be praying, he affirms “… now he is praying, and now I'll do't. And so, he goes to heaven and so am I revenged. A villain kills my father, and for that, I, his sole son, do this same villain send to heaven” (Act 3, Scene 3, Lines 77-83). Principally stating that although the easy route, being killed whilst praying would glorify King Claudius’s legacy and therefore counteract his father’s honour.
However, Hamlet is ignorant of the fact that Claudius was lamenting that his prayers are empty because of his inaction to repent for the violence and pain he has caused. This was a good chance for Hamlet to kill Claudius before Hamlet felt driven to kill Polonius, thinking it was Claudius (another example of dramatic irony, since only the audience and Gertrude know that Polonius was behind the curtains), as well as before Laertes could kill him.