Near the end of Hamlet as Hamlet is dying he asks Horatio to tell his story. Horatio does so when Fortinbras enters with his army. Horatio stands apart from the other characters in Hamlet in several ways, making him the logical choice to tell Hamlet's story.
Horatio is Hamlet's best friend. He is the only person who knows about Claudius killing Hamlet's father, the only person that Hamlet confides in. Hamlet lies to or tries to trick everyone else in his life. Horatio knew about the ghost of Hamlet's father, about the murder, about Hamlet's pain at his mother's marriage and about Hamlet's plan to try kill Claudius.
Horatio is also absent for most of the action of the piece. He is not there when Hamlet acts crazy, when Ophelia or Rosencranz and Guildenstern try to coerce answers out of him, when Ophelia dies. He is absent from all the speculation and accusations about Hamlet.
Because Horatio is Hamlet's confidant and because he is separate from the action he is qualified to tell Hamlet's story. Hamlet has been maligned through the whole piece so Shakespeare ends the play with his best friend defending him.