The theme of retributive justice is at the heart of Hamlet. Hamlet's quest is to exact revenge on Claudius for the murder of Old Hamlet. He is careful to exact perfect revenge. First he tries to discover if Claudius is indeed guilty.
The play's the thing to catch the conscience of a king.
When he is satisfied that Claudius is indeed guilty of murder, Hamlet's goal is to have a just revenge: an eye for an eye, in other words. He wants Claudius to suffer as much as his father did. Therefore, he will not kill Claudius when he is praying. He wants to wait until his "soul is sick with sin" so that Claudius will have a fate equivalent to that of his father who is now in purgatatory.
But Shakespeare also explores the idea of the consequences that taking revenge have on the avenger. How does the act of seeking revenge transform the avenger? We see Hamlet change from a depressed young man to a cold-hearted and ruthless murderer. He continually questions the act of revenge and wonders if he is a coward for not acting.
Further, Shakespeare uses Laertes and Fortinbras as foil characters to show other ways of attempting to achieve retributive justice. Each is also an avenging son, and each acts much more rashly than does Hamlet.