A theme is an underlying message that the author is trying to get across to the reader.
In Shakespeare's Hamlet, there are several themes in Act 5. One theme is that we don't appreciate something until after we lose it.
Until Act 5, Scene 1, Hamlet has been insulting and cruel toward Ophelia. He knows that Ophelia has been asked to spy on him and share her news with Claudius and Polonius. Hamlet feels betrayed. In her favor, Ophelia really has no choice: how can she defy her king and her father? Hamlet, however, is on the offensive as soon as he discovers his father has been murdered and begins to act strangely. Had he had faith in her and told her, as he did Horatio, to believe in him and keep his secret, Ophelia might have been an advocate and supporter.
By the time Hamlet mistakenly murders her father, Ophelia has lost her mind. And yet, when he discovers that she is dead, he is devastated, though he acted as if he hated her. We may then be surprised when Hamlet jumps into her grave and begins to fight with Laertes, insisting that he loved her more than anyone, as seen in Act 5, Scene 1:
I loved Ophelia. Forty thousand brothers
Could not, with all their quantity of love,
Make up my sum. What wilt thou do for her?
Another theme in Act 5 relates to hatred making strange bedfellows, or "My enemy's enemy is my friend." In Act 4, Claudius is quickly confronted by Laertes to account for Poloniuss' murder. Claudius, of course, calms the young man by blaming Hamlet. He also then uses Laertes's anger over his father's death to manipulate him into killing Hamlet. We know that all Claudius wants is the throne, and he will destroy anyone or anything to keep what he has:
If he be now return'd (65)
...I will work him
To an exploit, now ripe in my device,
Under the which he shall not choose but fall;
And for his death no wind of blame shall breathe, (70)
But even his mother shall uncharge the practice,
And call it accident.
My lord, I will be ruled;
The rather, if you could devise it so
That I might be the organ. (75)
This plan, then, is carried out in Act 5, Scene 2. Laertes enters into a dishonorable plan to murder Hamlet. It costs him his life. Claudius's conniving is responsible for the death of almost everyone involved in the final scene. However, Claudius is also punished. He is killed by his own treachery.