Who was Horatio?
Horatio is a character created by Shakespeare for the specific purpose of acting as a friend and confidant of Hamlet. In most plays information is conveyed to the audience through dialogue. Hamlet is in an awkward position because there is nobody he can trust at the Danish court, and so he cannot confide in anybody. That is why the play contains so many of his monologues. Shakespeare must have felt that he could have only so many of these lengthy monologues. At best, monologues and asides are awkward because people do not ordinarily talk to themselves about how they feel, what they are thinking, planning, etc. Besides that, they are not usually very dramatic. With Horatio as his trusted friend, Hamlet can discuss his secrets in a natural manner and thereby convey much essential information to the audience. For example, he can tell Horatio all about how he discovered the King's bellerophonic letter in the possession of Rosencrantz and Guildenstern aboard the ship bound for England, what he did about it, how he got captured by the pirate ship, etc. This could hardly have been handled in another monologue.
Not much is revealed about Horatio except that he and Hamlet were fellow-students at Wittenberg and that Horatio does not belong to a wealthy or aristocratic family. He seems very much like Hamlet's alter-ego. He is intelligent and perceptive, like Hamlet. He understands everything quickly. He is entirely in sympathy with Hamlet, probably because of the friendship they established at the university, where some of the best and longest lasting friendships are made between young people.
Horatio is not only invaluable to Hamlet during all of his friend's tribulations, but he is the only major character to remain alive when the play ends. This is important because the audience must not be left wondering what the other survivors would be thinking about the carnage they had just witnessed. How would the courtiers know, for example, why Hamlet had just murdered King Claudius in such a violent manner? Horatio knows everything. He has either observed events personally, or else he has received explanations from his good friend Hamlet. Shakespeare takes care to avoid leaving any loose ends by having Hamlet tell Horatio in his dying words:
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. (Act V, Scene 2)
Shakespeare was not really so much concerned about protecting Hamlet's name as he was about leaving his audience with the assurance that the survivors would be fully informed about the complicated events leading up to the deaths of Polonius, Rosencrantz, Guildenstern, Laertes, Gertrude, Claudius, and Hamlet. Only Horatio could explain everything from Claudius' murder of his brother to Hamlet's ultimate revenge-killing of Claudius. It was not necessary, however, for Shakespeare to include a scene in which Horatio explains everything to those who are left alive. This would be somewhat tedious because Shakespeare's audience already knows everything Horatio could say. There was no need for Horatio to explain anything to the audience, but there was a definite need for Horatio to explain everything to the people in the play who were left alive, including Fortinbras, and who would be astonished and perplexed by what they had just seen. Without Horatio, there would be endless conjectures; with Horatio, everything would be wrapped up, and the past could be put behind.