The question of whether Hamlet is truly mad or is pretending is continually debated. If he were merely pretending to be mad, why he would do so. One explanation is to protect his life.
After learning from the ghost that his mother had an adulterous affair with Claudius and that Claudius had murdered his father, Hamlet refuses to tell Horatio and the others what the ghost had said to him. (1.5.138-139). He trusts no one. He swears them to secrecy about the ghost. He also makes them swear not to give him away if he appears to act mad:
“Here, as before, never, so help you mercy, how strange or odd soe’er I bear myself as I perchance hereafter shall think meet to put an antic disposition on, that you at such times seeing me, never shall . . . note that you know aught of me.” (1.5.168-178).
Hamlet is rival to Claudius for the throne. He wants to be king. (5.2.65). He is popular with the people (4.3.4; 4.7.18). Claudius is afraid of Hamlet. (3.3.1-7). He refuses to permit Hamlet to return to school at Wittenberg, so he can be watched, in effect putting him under house arrest. (1.2.112-116). Hamlet says that Denmark is a prison. (2.2.239). Having learned from the ghost that Claudius killed King Hamlet to gain the throne, Hamlet is fearful that Claudius might kill him to retain it. Hamlet was perhaps inspired by the example of King David who pretended to be mad to save his life:
“And David laid up these words in his heart and was sore afraid of A’chish the king of Gath. And he changed his behavior before them, and feigned himself mad in their hands, and scrabbled on the doors of his gate and let his spittle fall down upon his beard. Then said A’Chish unto his servants. Look ye see the man is mad wherefore have you brought him to me? Have I need of mad men, that ye have brought this fellow to play the mad man in my presence? Shall this fellow come into my house? David therefore departed thence and escaped. . . . (1 Samuel, 21:12- 22:1).
Hamlet might also have been persuaded by the belief that insane people are under divine protection.
Hamlet was successful. Many believe him to be mad: Claudius (3.1.2-4; 3.3.2; 4.1.19; 5.1.262), Gertrude (3.4.103; 4.1.7-11,25), Polonius (2.1.107;2.2.49, 92,148), Ophelia (2.1.82-84; 3.1.150,156-160), Rosencrantz and Guildernstern (3.1.7), and the grave digger (5.1.142). Even Hamlet himself, proclaims that he is mad (3.1.146-147; 3.2.309; 5.2.217-224).
Claudius had some doubts about Hamlet’s madness (3.1.162-165). He dismisses them and continues to believe him mad.(3.1.189). Hamlet does confess that he is not really mad. He says to Gertrude, “I essentially am not in madness, but mad in craft”. (3.4.186-187). He also says to Rosencranz and Guildernstern that he is not mad (2.2.368-369).
Why does Hamlet wait and not act and kill Claudius to revenge his father’s murder as he had sworn to do? He did not act to protect himself until he could get verification that what the ghost told him was true. (2.2.583-589). He wanted to be king. Therefore, he wanted it commonly known that Claudius had murdered King Hamlet so his act of killing Claudius would be seen as justifiable revenge. Otherwise if he killed Claudius and said that he was told by his father’s ghost of Claudius’ deed, no one would have believed him. They would have thought him a homicidal maniac and would have treated him accordingly. There would have been no chance of him becoming king. By having the players re-enact the murder, which upset Claudius, he had proof and it was clear to those at the play of Claudius’ guilt. It was immediately thereafter, that Hamlet decided to kill Claudius, first at prayer and then in his mother’s apartment, killing Polonius by mistake.
Once Hamlet has revealed to the Court that Claudius had killed King Hamlet and after he had killed Polonius believing him to be Claudius, his madness is no longer protection. Claudius realizes that Hamlet knows of the murder and wants to kill him. He decides to kill Hamlet.
In the end, both Hamlet and Claudius die.