Hamlet is already distraught at the death of his father. When the ghost (of Hamlet's father) tells Hamlet that Claudius is his murderer, Hamlet becomes even more horrified and outraged. He will avenge his father. When the ghost exists, Hamlet begins a soliloquy in which he attempts to build himself up and put all of his efforts on revenge. He gives himself a pep talk as he tries to will himself to be completely determined on avenging his father. He says he will empty his mind of everything else. All of his thoughts will be set on revenge:
Yea from the table of my memory
I'll wipe away all trivial fond records,
All saws of books, all forms, all pressures past,
That youth and observation copied there;
And thy commandment all alone shall live
Within the book and volume of my brain. (I.v.103-08)
But Hamlet is also upset that he must undertake this revenge. He is an academic, a thinker. It goes against his nature to kill someone. He moralizes and thinks through things with great complexity. This will become one of the play's central themes. Hamlet swears revenge, but because he is such a deep thinker, he will consider every option and scenario in exactly how to kill Claudius, thus delaying his revenge repeatedly.