Is Hamlet's morality responsible for driving his actions throughout William Shakespeare's Hamlet, or is it something else?
This is an interesting question and probably has to be answered with a "but," as in "yes, but...." We are almost always moved to act--or refrain from acting--by multiple things rather than just one thing, and the same is undoubtedly true of Hamlet in William Shakespeare's Hamlet. There is ample evidence that Hamlet has a strong sense of morality which drives his actions in this play; when his moralities clash, Hamlet is indecisive and hesitates to act. Ultimately this indecision costs many lives, including his own. Having a strong morality does not make Hamlet weak; in fact, it serves as his guide about when to act and how throughout the play.
One of Hamlet's moral values is friendship. He is a loyal friend and he expects his friends to be loyal in return. Horatio is an example of a true friend, and Hamlet respects and trusts him enough to confide in him. Horatio is the only person in the play to whom Hamlet speaks freely, evidence that this is a true friendship. When two other friends betray him by spying on him for Claudius, Hamlet has no compunction about sending them to a prompt and certain death. He acts based on his moral code.
Another of Hamlet's moral values is loyalty. Because he loves Ophelia, he tries to warn her to leave ("get thee to a nunnery") and to dissuade her from loving him. Unfortunately, he is not clear enough with her about his reason for doing this and Ophelia commits suicide, but he did try. Gertrude, on the other hand, is not loyal in Hamlet's view, and he is merciless with her, someone he has loved for many more years than he loved Ophelia. Once again, he is not afraid to act.
Hamlet values family, as well. When his father's ghost asks him to avenge his murder, Hamlet readily agrees out of love for his father. When his mother "repents" of her sin of marrying Claudius, he forgives her and even confides the truth to her that he is only "mad in craft."
Hamlet values life, both his own and others'. He contemplates suicide but cannot do it because he believes in God's laws.
He hesitates many times to kill Claudius for a similar reason; he knows that killing a king, even a king who usurped the throne, puts his own eternity at risk.
Finally, Hamlet values justice. When he finally has the confirmation he needs to be certain Claudius was the one who murdered his father, Hamlet still hesitates because Claudius appears to be making his confession, and Claudius's death at that moment is not a fair exchange for his own father's death which occurred before he could make his last confession. It is not weakness or indecision but his sense of justice which keeps Hamlet from acting then. As soon as he catches someone he presumes is Claudius spying on him in Gertrude's chamber (an unconfessed sin), Hamlet is quick to act; unfortunately, he kills the wrong man. When his morality allows him, however, Hamlet is not afraid to act.
It is true that Hamlet's actions often make him look erratic and his inactions make him look indecisive; however, he does appear to act pretty consistently within his own moral code throughout the play. While Hamlet's moral code is actually praiseworthy, people die because he follows it. His actions and inactions, all based on his morality, are the cause of trouble in this play, but it is trouble he did not initiate, choose, or want.