Hamlet announcing that he might pretend to be mad:
As I perchance hereafter shall think meet
To put an antic disposition on—
Later Polonius thinks:
... I have found
The very cause of Hamlet's lunacy.
He argues that it is because his daughter, Ophelia, has rejected Hamlet's advances. Hamlet, Polonius thinks, then:
Fell into a sadness, then into a fast,
Thence to a watch, thence into a weakness
Thence to a lightness, and, by this declension,
Into the madness wherein now he raves,
And all we mourn for.
Act 4, Scene 5, has an abundance of good quotes about Ophelia's madness. Lastly, here's Hamlet's Act 5, Scene 2, apology to Laertes in which he argues that his madness is responsible for most of his behaviour:
What I have done
That might your nature, honour, and exception
Roughly awake, I here proclaim was madness.
Was't Hamlet wrong'd Laertes? Never Hamlet.
If Hamlet from himself be taken away,
And when he's not himself does wrong Laertes,
Then Hamlet does it not, Hamlet denies it.
Who does it, then? His madness. If't be so,
Hamlet is of the faction that is wrong'd;
His madness is poor Hamlet's enemy.