In "Hamlet" the young prince is greatly disturbed by the death of his father and by the precipitative marriage of his mother and his uncle. So he is stunned by the suddenness of events. Added to this, he does not know whether the ghost of his father which urges Hamlet to avenge his death is real or not. Also, since the Danish people are fickle (many of them come to Laertes's cause against the Prince later) and killing a king is a weighty matter, Hamlet delays. And, finally, his is simply not a personality given to immediate action. He is repulsed by his mother's hasty action and condemns it:
O, such a deed/As from the body of contraction plucks/The very soul, and sweet religion makes/A rhapsody of words. Heaven's face does glow/O'er this solidity and comoun mass/With heated visage, as against the doom--/Is thought-sick at the act(III,iv,42-49).
For, Hamlet is a procrastinator, a ponderer, a melancholic thinker given to philosophy and abstraction--even depression. It is difficult for Hamlet to act when he is consumed with his thoughts:
How all occasions do inform against me,/And spur my dull revenge! What is a man,/If his chief good and market of his time/Be but to sleep and feed? A beast, no more...(IV, iv, 32-35).
Hamlet's brooding inaction brings about more depression for the Prince of Denmark. His preoccupation with the loss of moral beauty and his desire to die himself ( "To be or not to be.....") bring about Hamlet's fatal error of not killing Claudius. His pretense of being mad seems a ruse to bring out the truth in his imagined foes such as Polonius and Ophelia. Against Rosencrantz and Guildenstern, Hamlet feigns his madness because he knows that they conspire against him.
The complexity of Hamlet's character is what gives the play such depth. Perhaps, too, his one response to Rosencrantz and Guildenstern is very telling:
...for there is nothing either good or bad, but thinking makes it so....(II,ii,241-242)