This line is Horatio's tribute to his dead friend and prince, Hamlet. It comes directly after Hamlet's final line of the play:
O, I die, Horatio;
The potent poison quite o'er-crows my spirit:
I cannot live to hear the news from England;
But I do prophesy the election lights
On Fortinbras: he has my dying voice;
So tell him, with the occurrents, more and less,
Which have solicited. The rest is silence.
Hamlet dies not knowing what the fate of Rosencrantz and Guildenstern was, but knowing that Fortinbras has come from Norway and will take over Denmark as its King. Horatio replies, to the audience and the surrounding crowd on the stage:
Now cracks a noble heart. Good night sweet prince:
And flights of angels sing thee to thy rest!
He is merely saying goodbye to his friend. Horatio is the only person in the play who understands Hamlet's "noble heart," so it is fitting that he is the person who sends him to heaven in eloquence.
Hamlet is the definition of a Shakespearean tragedy. The main protagonist, Hamlet, loses everything that is important to him in the end and his life. Unlike Greek tragedies where the main character must suffer as a result of his actions and his burden is to live with the ramification of his tragic flaw (ex: Oedipus), Hamlet dies without being about to explain the conflicts he endures and his subsequent actions to his people prior to his death.
Horatio knows this when Hamlet is taking his final breaths. He understands what his friend sacrificed in order to avenge his father's death, and the torment Hamlet suffered at the hands of Uncle Claudius' plots to kill King Hamlet and Hamlet as well.
Upon looking at the dying Hamlet, Horatio says, "Now cracks a noble heart. Good night sweet prince:" in order to reinforce the characterization that Hamlet is not solely a negative force in the text, but at the heart of Hamlet's pursuit for revenge is his innocent and unconditional love for his father. Ultimately, Hamlet's character remained faithful and loyal to his country and his family. Although his pursuit for justice for his father and revenge for his father's murder undermined his relationships with his mother and Ophelia, Horatio implies that Hamlet's missteps and foul deeds are justifiable.
Ultimately, Horatio must live in order to tell the accurate story of Hamlet's tale of love and revenge and as a result the death and destruction left in his wake. Horatio can be trusted to inform the people of the real story rather than the assumptions they will make based on the evidence that remains.
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.
I believe you made a mistake by saying Horatio's death. As I am sure you know, it is Horatio's line directed, with respect, to his dead friend Hamlet.