If one assumes that Hamlet is indeed mad, the reasons are many: his father has been murdered by his uncle; his mother has married the killer less than two months after her first husband's death; Hamlet has returned to Denmark to find himself deposed; he is not allowed to return to college in Germany; his ghost-father has demanded that he exact bloody revenge for his uncle's crime and his mother's treachery.
However, there is ample evidence that Hamlet is not mad at all, but feigning insanity to "catch the conscience of a king." He goes to great lengths to "prove" his instability to everyone he knows, even to the point of abject cruelty to his former love, Ophelia.
Yet the scales towards madness tip again to true disorder when one considers the tactics Hamlet employs to to carry out his questionable mission. In the end, eight bodies scatter the stage, including that of Hamlet himself.
Part of Shakespeare's genius lies in not knowing when, if ever, Hamlet ever crosses that thin line.
For in-depth analysis of each scene of Hamlet, you may want to visit my Literature 101 blog here at eNotes and participate in group discussions. See the first link below.