Horatio certainly does not die at the end of the play, although he does attempt to commit suicide by drinking the last of the poisoned wine in the cup. He tells Hamlet:
I am more an antique Roman than a Dane.
Here's yet some liquor left.
But Hamlet takes the cup away from him, saying:
Give me the cup. Let go. By heaven, I'll ha't!
O God, Horatio, what a wounded name,
"Things standing thus unknown, shall live behind me!
If thou didst ever hold me in thy heart
Absent thee from felicity awhile,
And in this harsh world draw thy breath in pain,
To tell my story.
Shakespeare is really mainly concerned about the impression that will be left with his audience. If Hamlet died without leaving someone behind who could explain what had happened from start to finish, the audience would feel somewhat dissatisfied with the conclusion. All the principals would be dead--Claudius, Gertrude, Polonius, Ophelia, Rosencrantz, Guildenstern, and Hamlet. It would look to the courtiers as if Hamlet murdered Claudius and also murdered Laertes with a poison-tipped foil in their duel. But if Horatio remained alive, he could explain everything to the people in the court, to the commoners, and to the new king Fortinbras. Horatio knows everything that happened, including Hamlet's meeting with his father's ghost, which he personally observed. Horatio knows that Claudius was guilty of murdering his brother and seizing his crown and his wife. Horatio witnessed Claudius' behavior at the play within a play, where the king revealed his guilt. What Horatio has not personally observed, he has learned directly from his friend Hamlet. It was therefore essential that Horatio remain alive to leave Shakespeare's audience with a feeling that there was a full and proper closure.