What events led up to Hamlet's death?
In rough order, Claudius' murder of his brother, Hamlet's father, set things in motion; Gertrude's marriage of Claudius sped them along.
When the ghost of Hamlet's father returned and put the burden of justice on Hamlet, he couldn't leave things rest—but every time he waffled he let things get further out of hand.
His accidental killing of Polonius further unbalanced things.
The most immediate cause of Hamlet's death, though, is the poison on Laertes' sword.