Hamlet is driven insane because of the unbelievably inappropriate nature of the marriage between his uncle and mother--a union that arose out of betrayal, political motivation, and murder.
Early on in the play, Hamlet learns from the Ghost (who actually is the spirit of Hamlet's dead father, the late king) that Hamlet's father was murdered. The perpetrator of this crime was Claudius, the brother of Hamlet's father. Claudius has since assumed the throne and married Hamlet's mother, Gertrude. This, as the Ghost explains, is a "foul and most unnatural murder," one committed by an "incestuous... adulterous beast." By pouring poison into the King's ear, Claudius managed to steal his brother's life, crown, and wife all at once; this act is made even worse by the fact that Hamlet's father was killed without having had the opportunity to confess his sins and save his mortal soul.
With all this in mind, Hamlet decides that he must avenge his father's death. It is arguably this violent and difficult pursuit--along with the mind-boggling details of his uncle and mother's involvement--that lead Hamlet to go insane.