According to Hamlet's father's ghost, Claudius has murdered Hamlet's father. Hamlet's father's ghost instructs Hamlet to avenge his death. Hamlet's father's ghost tells Hamlet that he is obliged to seek revenge:
So you are obliged to revenge, when you shall hear me.
The ghost of Hamlet's father adds that Hamlet is to avenge a most terrible murder:
Revenge his foul and most unnatural murder.
Hamlet responds that he will seek revenge immediately:
Tell me about it quickly, so that I, with wings as swift
As meditation or the thoughts of love,
May rush to my revenge.
Although Hamlet states that he will act quickly while seeking revenge, Hamlet does not react immediately. As a result of Hamlet's inaction, he experiences melancholy. Hamlet becomes depressed because he cannot seem to avenge his father's death quickly enough. While Hamlet debates with himself on whether or not to kill his Uncle Claudius, he becomes more and more despondent. Hamlet desires to avenge his father's death, but he procrastinates and seems to be uncertain as to what action he should take. In his most remembered soliloquy, Hamlet questions whether or not he should kill Claudius or just suffer with the images he has of Claudius murdering his father:
To be, or not to be, that is the question.
Is it nobler in the mind to suffer
The slings and arrows of outrageous fortune
Or to fight against a sea of troubles,
And end them by fighting?
Clearly, Hamlet is experiencing depression. He is in a melancholy state of mind. He seems to want to die. He is definitely depressed over his situation. He is confused over which decision to make. Should he kill Claudius or just suffer with the thoughts of his father's murder by Claudius. No doubt, Hamlet is wrestling with a desire to die:
To die, to sleep,
Nothing more, and by sleeping, to be able to say we end
The heartache, and the thousand natural shocks
That the body gets as part of life is an ending
To be wished for very earnestly.
In this most famous soliloquy, Hamlet indicates that he wishes for death. He is sinking lower and lower in despair:
I have of late, but why I don’t know,
lost all my joy, given up all habits of exercises, and
indeed, I am so depressed that this good frame, the
earth, seems to me to be a sterile outpost, this most
excellent canopy, the air— look—, this brave sky hanging
over us, this majestic roof divided with golden fire, why, it seems to me to be nothing but a dirty and disgusting
meeting of vapors.
He is so down on himself until he questions whether or not he is a coward for not acting soon enough to avenge his father's death:
Am I a coward?
Ultimately, Hamlet finds the courage to avenge his father's death. In so doing, he kills Claudius. Sadly enough, Hamlet is wounded and dying as well. Finally, his melancholy is over for he has brought about justice. His father's death is avenged. Hamlet can die in peace.