The murder of the King Hamlet is a terrible crime made worse by the fact that the murderer is his brother, Claudius, who then goes on to 'steal' his wife, Gertrude. Throughout the play Hamlet berates himself for failing to carry out the execution of Claudius: he notes that the first player (actor) shows more passion in and commitment to his fictional role than than he himself shows in the real role of his father's avenger. He feels it is his moral obligation to kill Claudius - he just can't do it!
When Hamlet first receives the Ghost's instruction to kill Claudius, he says in the soliloquy which follows,
'thy commandment all alone shall live / Within the book and volume of my brain'.
The use of the word 'commandment' makes it seem like a religious instruction; he does not doubt that killing Claudius is the right thing to do. However, very shortly afterwards he says to Horatio,
'O cursed spite, / That ever I was born to set it right!'
What he doubts is that he is the right man for the job.
In the most general sense of differentiating right and wrong, I think Shakespeare argues that revenge is wrong. So I don't see Hamlet as having a moral obligation. There are a number of places where Shakespeare contrasts honorable military endeavors with revenge and the two are opposites. There is Pyrrhus who because of his revenge on Priam is remembered as a beast. Then Laertes uses the guise of sword play to exact his revenge and acknowledges his "treacherous instrument" and his "foul practice" that brings about his own death. Prince Fortinbras though initially bent on revenging his father's death is reined in by his uncle. He goes on to exhibit admirable military qualities and in the end gains the throne of Denmark. King Hamlet likewise is remembered honorably as a military man.
What is interesting about the play is how Hamlet learns about revenge and its difficulties. In his soliloquy right after the ghost departs he expresses the burden that has been placed on him as a duty: a "commandment". But, in Hamlet's mind burdens are borne by beasts not by nobility. Hamlet through the whole play wrestles with this beast/nobility dichotomy. But I digress.
There is something more that compels Hamlet beyond the raw command of the Ghost. Aside from establishing the veracity of the Ghost, Hamlet tells us in his last soliloquy in 4.4 that he has "cause". Hamlet can then regard the Ghost purely as an informant. Hamlet's cause is expressed later in the play in 5.1 when confiding in Horatio:
Does it not, think'st thee, stand me now upon--
He that hath kill'd my king and whored my mother,
Popp'd in between the election and my hopes,
Thrown out his angle for my proper life,
And with such cozenage--is't not perfect conscience,
To quit him with this arm? and is't not to be damn'd,
To let this canker of our nature come
In further evil?
Do anyone of these provide a moral justification? Or obligation as you say? Good question. Does it cease to be revenge when Claudius's evil is revealed? Perhaps so. Within the context or world of the play of course.