In Shakespeare's Hamlet, Polonius thinks Hamlet is insane or "mad," because Hamlet wants him to think he is mad--it's part of his plan.
In Act 1.5.171, after Hamlet has been told by the Ghost that Claudius killed King Hamlet, Hamlet tells Horatio that he may put an "antic disposition on," or fake madness, and that Horatio should not let on that Hamlet is just faking. The Ghost gives his blessing, so to speak, to the plan by calling out for Horatio to "Swear" he will do as Hamlet asks.
Ophelia incorporates herself into Hamlet's plan by obeying her father and returning his letters to him and denying him access to see her. She later tries to spy on Hamlet while engaging him in a conversation as Polonius and Claudius listen. Thus, Hamlet uses her to reveal his "madness," knowing, presumably, that his antics will get back to the king, which they eventually do, of course.
When Hamlet grabs Ophelia's arm and studies her face as if he were an artist, sighs as if he were dying, then walks away without looking where he's going, he is pretending to be mad. He wants the king to be preoccupied with Hamlet's madness, rather than with the fact that Hamlet is going to revenge his father. He acts mad so Polonius will think he's mad. And it works.
In Act 2, Scene 1, a very upset Ophelia enters the stage and tells Polonius, her father, that something is wrong with Hamlet. He spoke to her and he was looking very strange, all bedraggled. She relates that Hamlet grabbed her and held her for a long time, sighing, but not speaking. Polonius assumes that Hamlet is mad over his love for Ophelia. Earlier, Polonius had told Ophelia to stay away from Hamlet because he was a prince and their relationship was probably not a good idea. Even though Ophelia loves Hamlet, she obeys her father. Now, Polonius assumes that Ophelia’s actions towards Hamlet have probably made him mad, so he leaves to tell the king, Claudius about his idea. Later, Polonius hides behind a curtain in Hamlet’s mother’s room to spy on Hamlet to see what he has to say and to see if he is right about thinking Hamlet mad. Hamlet thinks it is the king and stabs through the curtain, inadvertently killing Polonius.