William Shakespeare's Hamlet is a revenge tragedy full of murder and almost-incestuous relationships. Those do not sound like the typical elements of a story that is at all concerned with religious themes; however, the issues of mortality and the afterlife play a significant role in this play.
Hamlet was written in the 16th century in England, when religion was a tremendous source of violence and anxiety. The Protestant Reformation introduced a new kind of religious thinking to the English people, and the way Catholics and Protestants saw the important issues of life and death were still confusing to people at this time.
We know that Hamlet's constant indecision is the cause of most of the trouble he and other characters face throughout the course of the play; consider the reason for his indecision. We hear it from him almost from the first time we meet him, and it is a consistent theme throughout the play.
Hamlet is despondent because his father is dead and his mother has remarried much to quickly--and her new husband is her old husband's brother. That would cause some consternation for a young man who is sensitive to the issues of life, death and the afterlife. In his first soliloquy, Hamlet says:
O, that this too too solid flesh would melt
Thaw and resolve itself into a dew!
Or that the Everlasting had not fix'd
His canon 'gainst self-slaughter!
Clearly the only reason he does not commit suicide is because he believes God ("the Everlasting") has proclaimed it a sin.
Later, in Act III, Hamlet speaks these lines in a soliloquy:
Who would fardels bear,To grunt and sweat under a weary life,But that the dread of something after death,The undiscovered country from whose bournNo traveler returns, puzzles the willAnd makes us rather bear those ills we haveThan fly to others that we know not of?
Hamlet both acts and fails to act because of his religious beliefs. Denmark and nearly everyone in this play is impacted by those actions and inactions: Polonius, Ophelia, Laertes, Claudius, Gertrude, Hamlet, and even Horatio and Fortinbras.
While Hamlet is set in Protestant Denmark, it was rumored that Shakespeare, whose father John was a Roman Catholic, was a closet Catholic. Perhaps, this explains why some of the doctrine of Catholicism emerges in this play.
At any rate, Hamlet continues his own life and allows Claudius to continuing living as he restrains himself from committing two murders because of his religious beliefs.
1. [Notice the use of the word canon, which is used in Catholicism]:
O, that this too too sallied flesh would melt,
Thaw, and resolve itself into a dew,
Or that the Everlasting had not fixed
His canon 'gainst self-slaugher. (1.129-132)
Hamlet is motivated to not commit suicide, even though he would like to die, because he believes it is a mortal sin and he would go to hell. (Later on, Ophelia cannot be buried on consecrated ground because she killed herself as Catholicism forbade such burials.)
2. As Hamlet watches Claudius pray after leaving the Dumb Show in which the king is murdered by poison being poured in his ear in imitation of Claudius's heinous act against his brother Hamlet.
O, my offence is rank, it smells to heaven;
It hath the primal eldest curse upon't
A brother's murder. Pray can I not,
Though inclination be as sharp as will.
My stronger guilt defeats my strong intent, (3.3.
When he hears Claudius confess his fratricide, Hamlet sees his opportunity for revenge, but he changes his mind as he realizes that with Claudius at prayer, his murder would make the villain a martyr (another Catholic concept), "purging his soul" (3.3.85), and send him to heaven. So, Hamlet waits so that "his [Claudius's] soul may be as damned and black/As hell... (3.3.94-95).
Religion plays a huge part whether this is in reference to the King or the old King. When Hamlet has the perfect chance to kill Claudius, he does not because he believes that Claudius is praying to heaven. If Claudius prays to heaven when he is killed then he will go there and Hamlet wants Claudius to suffer and go to Hell. This is only one example of the many examples found in the play Hamlet.