Horatio's friendship with Hamlet extends sufficiently far that, in his genuine concern for Hamlet's safety, Horatio is willing to rebuke and point out the possible consequences of what he regards as Hamlet's rasher actions. Hamlet indeed recognizes the value, objectivity, and validity of Horatio's judgment when he calls him "as just a man/ As e'er my conversation coped withal" (3.2.56-57). Shortly after these words of praise, Hamlet selects none other than Horatio to observe Claudius's reactions to the performance before them and act as an independent party verifying the king's guilt in his predecessor's murder on the basis of his response. Indeed, Horatio's confirmation of Hamlet's suspicion is integral for Shakespeare to even convey the certainty of Claudius's guilt to the reader, who might have up to that point questioned the reliability of Hamlet's perceptions and personal conjectures on this subject. Even more importantly, Hamlet himself had beforehand doubted Claudius's culpability, stating, "The spirit I have seen/ May be a devil..." (2.2.627-8) and thereby questioning the validity of the accusation leveled against Claudius by the ghost of Hamlet's father.
However, once Horatio conducts his independent observations, which Hamlet knows to have been formed without an inclination to automatically favor the prince's interpretation, there is no longer any ambiguity in Hamlet's mind on this matter. As the play progresses, Horatio's judgments begin to assume even greater significance. Horatio attempts to dissuade Hamlet from accepting the king's offer for him to duel with Laertes, and perceptively informs the prince, "You will lose, my lord" (5.2.223). Horatio senses that Claudius has laid a trap for Hamlet and urges that the prince's mind overcome the rashness of his passions and rethink his rush into death, stating, "If your mind dislike anything, obey it" (5.2.231). Though Hamlet disobeys Horatio's advice, Shakespeare uses the very presence of these warnings to suggest that Horatio's voice of reason is an element immensely important and friendly to Hamlet's interests. Indeed, had Hamlet heeded Horatio's words of caution, he might have lived.
The purpose toward which Horatio uses his judgment, his staunch personal loyalty to Hamlet's well-being, is an equally crucial component of the relationship between the two. So great is this devotion that Horatio becomes Hamlet's confidant with regard to Hamlet's suspicions of Claudius's guilt. Before any member of the court has any evidence of the king's murderous nature, Horatio is nevertheless willing to grant Hamlet's plan a fair trial, and Hamlet trusts Horatio not to reveal his immensely dangerous secret to anyone else.
This trust is warranted, as Horatio is willing to go as far as to assert personal responsibility for the outcome of Hamlet's plan, stating of the king, "If he steal aught the whilst this play is playing/ And 'scape detecting, I will pay the theft" (3.2.94-5). From that moment on, Horatio plays a prominent role in Hamlet's designs against Claudius. Upon Hamlet's escape from the vessel destined to bring him to England and to his death, he sends a lengthy private letter to Horatio, explaining the events causing his return to Denmark and signed, "He that thou knowest thine" (4.6.30), indicating Hamlet's reciprocation of Horatio's loyalty. The letter contains details and clandestine designs that would be unsuited for the eyes of Claudius, who, in contrast to Horatio, receives an extremely brief letter merely indicating Hamlet's forthcoming return. Once again, Hamlet can rely on Horatio not only to keep his secret, but to arrive promptly at Hamlet's side as well.
Shakespeare uses the events of the play to confirm Hamlet's evaluation of Horatio's character, as, indeed, the reader finds the two of them in each other's company at the opening of the fifth act. Horatio's steadfast adherence to Hamlet's interests is a stark contrast to the attitudes Hamlet observes in others of the Danish court. Polonius may flatter Hamlet for the latter's every whimsical expression, yet does so not genuinely, undertaking such conduct merely because praising a prince to his face is expected from a servant of royalty. Rosencrantz and Guildenstern are willing to betray a childhood friendship with Hamlet in order to heed Claudius's request to spy on him.
Even Hamlet's beloved, Ophelia, does not display toward him the genuine loyalty he desires, willing to repel Hamlet's letters and deny him the ability to visit her due to a mere command from her father. Only Horatio disallows such motives as expediency, favor-seeking, the desire to flatter, and obedience to the dictates of others from interfering with his genuine and principled adherence to the welfare of his friend. Hamlet, skilled in the contemplation of abstract principles, recognizes one such principle, loyalty, as consistently applied by Horatio, and thus gravitates toward a friendship with him. So immense is Horatio's devotion to Hamlet at the end of the play that he contemplates drinking from a poisoned cup, calling himself "more an antique Roman than a Dane" (5.2.374), thereby indicating that his life's meaning has been antiquated since he would no longer be able to exercise his primary moral purpose of loyalty to Hamlet due to the latter's imminent death.
Yet Hamlet has other designs for Horatio's life, and urges his friend to live on and perpetuate his devotion to the prince by serving as a reliable transmitter of Hamlet's story and legacy. Hamlet appeals to the motive of loyalty when he instructs Horatio, "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" (5.2.381-4). Though the possibility of Horatio's death is immensely undesirable to Hamlet, as it would leave behind the prince's tarnished name and unexplained deeds, Hamlet does expect Horatio to forgo worldly pleasures and bear the burden of accounting for the prince's motives and mistakes. This is a task Hamlet admits to be uncomfortable, but a necessary extrapolation upon the bond of friendship established between Hamlet and Horatio during the prince's life.
Hamlet's selection of Horatio for this undertaking also reinforces his confidence in Horatio's objectivity and clarity in relating events as they happened, and Shakespeare himself uses these events to sway readers toward a concordant judgment. After all, Horatio is the sole man remaining to convey an accurate account of the happenings constituting the play. Since, through the play, readers indeed receive such an account, they are left to conclude that Horatio performed his job in accordance with Hamlet's expectations. Moreover, Horatio acts not only to reveal and perpetuate the memory of Hamlet's past, but also to implement Hamlet's wishes to affect the future. Horatio agrees to fulfill Hamlet's request to sponsor Fortinbras for the Danish succession and predicts the effect of such advocacy when he states that Hamlet's "voice will draw on/ more" (5.2.435-436), inspiring the living to support Fortinbras as well. Even in death, Hamlet's plans, values, and ideas continue to exert a real political influence due to the efforts of his steadfast friend in promoting them.
Shakespeare's Hamlet suggests that, when there are no more favors to seek and no more momentary advantages to elicit, remaining by a person's side is the true test of friendship, a test that Horatio passes with flying colors, as one cannot gain favors and advantages from a dead man. Hamlet rightfully recognizes the virtues of Horatio's independent judgment and loyalty, and, paradoxically, maintains a bond with him in death even stronger than the one they had in life. While living, Hamlet twice disobeys Horatio's advice as he follows the ghost and, later, commits the fatal error of accepting the proposal to duel with Laertes. However, during his last minutes, Hamlet demonstrates his complete trust of Horatio by investing him with the responsibility of transmitting his story through the ages, without any further oversight or objection from the prince. What stronger confidence in a friend can ever be manifested than this?