The overall theme of appearances vs. reality is one that ties in very neatly with the question of whether Hamlet is mad or not. At the end of the day, it seems very difficult to take one definitive view on this issue. On the one hand, after seeing the Ghost, Hamlet tells Marcellus and Horatio that he is planning to act mad, as he reveals in Act I scene 5:
As I perchance hereafter shall think meet
To put an antic disposition on--
It is no coincidence, therefore, that this scene is juxtaposed with Ophelia's distraught revelation to her father that Hamlet entered her chamber dressed in a manner suggesting complete madness:
Lord Hamlet, with his doublet all unbraced,
No hat upon his head, his stockings fouled,
Ungartered, and down-gyved to his ankle,
Pale as his shirt, his knees knocking against each other...
It would be easy therefore to dismiss this as a deliberate ploy by Hamlet. He has indicated to the audience that he intends to put on an "antic disposition," and this is his first example of the role he is playing. However, at the same time, it is possible to argue that Hamlet genuinely is not in his right mind. Note too that Ophelia says when he appeared before her thus attired his face bore a look "so piteous in report/As if he had been loosed out of hell/To speak of horrors." In one sense, this is precisely true: Hamlet had just seen "horrors" in the form of the Ghost, and particularly given the revelation that the Ghost shared with him as to how his father actually died, it could well be that Hamlet's sanity has been affected.
Overall, it seems as if there is more proof to suggest that Hamlet's insanity is just an act, as he plays his careful game throughout the play just as other characters play their games, and his plotting against Claudius certainly reveals lots of careful thinking and reasoning. However, equally this question is one that is never answered for the audience by Shakespeare.