There is little doubt that Hamlet's madness is indeed feigned. He explicitly mentions this in act 1, scene 5 when he refers to putting "an antic disposition on." But there are further instances where Hamlet makes it clear what he's up to. In act 2, scene 2, Hamlet is conversing with his old school chum, Guildenstern:
"I am but mad north-north-west: when the wind is
southerly I know a hawk from a handsaw."
In other words, Hamlet is only mad when it suits him. Otherwise, he's as sane as anyone else. But there's really no need for Hamlet to keep confessing to his sly trickery. Just about everyone in the play comes to realize, sooner or later, that his alleged madness is all just an act:
"Though this be madness, yet there is method in't."
That's Polonius, earlier on in act 2, scene 2. Claudius isn't wholly convinced, either, even though it's in his interests to think that Hamlet really has taken leave of his senses:
"What he spake, though it lack'd form a little.
Was not like madness." (act 3 scene 1)
Hamlet's feigned madness admirably serves his purposes. But it also serves the internal dynamic of the play by conveying real meaning to an audience. If Hamlet really were insane, then it would be difficult, both for us and the play's sane characters, to have any idea of what's going on. And with that, the play would lose psychological complexity and dramatic depth.