The primary reason Hamlet sets out on this quest to avenge his father's death is that the ghost of his father asks him to do so:
If thou hast nature in thee, bear it not.
Let not the royal bed of Denmark be
A couch for luxury and damnèd incest. (1.5.86–89)
And Hamlet commits himself to undertaking this role:
Haste me to know ’t, that I, with wings as swift
As meditation or the thoughts of love,
May sweep to my revenge. (1.5.34–36)
Hamlet knows that his uncle has stolen his father's wife, crown, and life, which leaves him reeling to find his own footing. After making this vow to his father, the prince spends most of the play hesitating to follow through on the vows he's made. He is utterly torn by his father's desires to exact revenge and his own inability to take his uncle's life—for reasons he can't even come to terms with himself. In act 4, he is still perplexed about why he allows Claudius to live:
I do not know
Why yet I live to say "This thing's to do,"
Sith I have cause, and will, and...
(The entire section contains 2 answers and 873 words.)