Hamlet is a revenge tragedy, which means we're in for a killing spree. (Bloodthirsty? You can read more about this in "Genre.") At the end, almost every character with a name has been offed in one gruesome way or another.
But all's not lost. Sure, the royal court has been utterly wiped out—and then in saunters Prince Fortinbras to claim the throne, restoring order and continuity to the court.
Plus, Horatio survived the mass killing, and he's promised to tell Hamlet's tragic story. He makes good on his vow as Hamlet dies: "Good night, sweet prince," he says, "And flights of angels sing thee to thy rest!" (5.2.397-398).
Horatio, whose name recalls the Latin term "orator," interprets Hamlet's death and salvation in the most elegant terms. The voices of angels, Horatio seems to suggest, will carry Hamlet to his heavenly "rest." Shakespeare seems to be making an explicit connection between Hamlet's eternal afterlife, the angelic voices that "sing," and the storytelling that Horatio undertakes at this moment. Because Hamlet's story will be told, he'll live on for eternity.
And judging by Hamlet's popularity, Shakespeare seems to be right.