In the play's final scene, poison kills (or aids in the killing of) Hamlet, Queen Gertrude (Hamlet's mother), Laertes (Polonius's son and Ophelia's brother), and King Claudius (Hamlet's uncle and step-father). Further, Claudius used poison to murder Old King Hamlet before the start of the play. Thus, poison is responsible for the deaths of the entire royal family as well as Laertes, who was once held up as a possible replacement king by the people.
When Marcellus said, "Something is rotten in the state of Denmark," he was right (1.4.100). It is as though corruption, since the old king's death by poison has spread -- like poison -- throughout the entire royal family. When Claudius poisoned the king, he set into motion the metaphorical spread of this "rot" until it consumes them all. Claudius was corrupted by the cruel murder he performed, Gertrude was corrupted by Claudius's deception and her own lust, Laertes was corrupted by his need for revenge (he does not behave honorably in his duel with Hamlet), and Hamlet was corrupted by his own inability to act and cowardice. Now, the entire royal family and the family closest to them have been completely ruined. However, with the spread of the poison, through all of their deaths, the rot has been eradicated and Denmark can now begin anew with fresh leadership.