Horatio, unlike Hamlet, is calm, level-headed, reasonable, and cautious more often than not. He initially doubts the existence of the Ghost, but once he sees it, Horatio logically decides that Hamlet must be informed. When the Ghost beckons Hamlet to follow him, Horatio is fearful that the Ghost may be an evil spirit, and he warns Hamlet, who recklessly ignores any potential danger.
Hamlet "puts an antic disposition" on, thereby pretending to be someone he is not, but Horatio is "not passion's slave." He is a stalwart friend, a reliable source of information for both Hamlet and at the end of the play for Fortinbras when Horatio explains the carnage. Although Horatio loves his friend and at first wants to follow him in death, Hamlet convinces him that Horatio must live to tell Hamlet's story to the world. Horatio is the only person whom Hamlet trusted enough to share his plans with before he eventually revealed to his mother that he wasn't actually mad.
As in many of his plays, Shakespeare has included a young man about the same age as the protagonist who shares some traits with him but contrasts in others. Horatio is a student as Hamlet is. His role is to serve as a confidant to Hamlet and to offer advice. As a foil, he calls out attention to Hamlet's main character traits as well.
Horatio serves as Hamlet's foil throughout the play and is his loyal friend. As was mentioned in the previous post, Horatio is trustworthy, rational, and level-headed. Hamlet confides in Horatio throughout the play, and Horatio is always quick to offer sound advice. In contrast, Hamlet hesitates to take action and makes a series of faulty decisions. Hamlet's decisions are based on his emotions, while Horatio has the ability to perceive the consequences of his actions. Hamlet is a risk-taker, and Horatio is not. For example, Hamlet follows the ghost while Horatio insists that he not follow the unfamiliar spirit. There are moments throughout the play where Hamlet is loquacious, while Horatio is not inclined to use elaborate wordplay whenever he speaks. Horatio is also more reserved and shows restraint, while Hamlet has a tendency to act impulsively. Hamlet also has a melancholy personality and is attracted to anything with a macabre atmosphere. In contrast, Horatio is a rather positive individual who has empathy for his friend. Horatio also does not conspire to murder or harm anyone, while Hamlet is inclined to seek revenge. Also, many of the characters throughout the play do not trust Hamlet and are concerned about his mental state. In contrast, Horatio is never questioned and is viewed as a trustworthy person.