Is Hamlet really insane or is he pretending to have gone mad?
This is one of the key issues of the play. After seeing the Ghost in Act I, Hamlet has resolved to seek revenge against Claudius. He swears his friends, who know only that he has spoken with the Ghost, to secrecy and then asks them to stay silent, no matter "how strange or odd some'er I bear myself (as I perchance hereafter shall think meet to put an antic disposition on." He warns them not to give away, by a knowing nod or a smile or a word, that he is implementing an unusual plan.
By Act II, Hamlet has been acting sufficiently "crazy" that others are questioning his sanity. Hamlet reveals to his former friends Rosencrantz and Guildenstern that he is "but mad north-northwest; when the wind is southerly I know a hawk from a handsaw." He's just told them he's not actually crazy, but they're too insensible to reason to recognize his revelation.
The next reference Hamlet makes to his feigned (or real) madness is is Act III when he has a confrontation with his mother. He tells her he is "essentially...not in madness but mad in craft"--of course he has just had a murderous outburst in which he stabs the man behind the arras (Polonius), Here, perhaps, we begin to wonder if he has somehow placed at least a toe across the line of sanity.
Immediately afterwards, in Act IV, Gertrude announces to Claudius that her son is "mad as the sea and the wind when both contend which is the mightier." Is that because she believes he is insane or to keep the King guessing about Hamlet's mental state? Probably the latter, as she immediately looks at the King with blame when she realizes she has been poisoned in Act V. Possibly the former, as she does nothing to help Hamlet until she reasons that her husband is the crazier one for having plotted and schemed in such a way.
Act IV is where Hamlet may move from feigned insanity to the real thing in his grief for Ophelia. He literally lashes out in his grief and even jumps into Ophelia's grave. After that, his spirit seems to be resigned to his fate, as exhibited in his last major conversation with Horatio. In any case, he is able to fight with Laertes and fulfill his promise to his father.
A case can be made for both mad and mad in craft. though it's certain madness in craft was a plan from the beginning.