The characters Horatio, Rosencrantz, and Guildenstern all function primarily as Hamlet’s friends or alleged friends. They are used in contrast to one another to stand for true friendship, exemplified by Horatio, and falsity and betrayal, in the case of Rosencrantz and Guildenstern. Another difference is that Horatio survives—one of the few characters who does—while Rosencrantz and Guildenstern end up dead, in both cases thanks to Hamlet.
Horatio is one of Hamlet’s two friends who beholds his father’s Ghost with him, to whom he confides his plan to feign madness, and who swear to keep the deception a secret. He is straightforward with Hamlet, advising him that the Ghost might be misleading him or even not real. Throughout, as Hamlet’s behavior gets increasingly stranger, Horatio stands by him and upholds his convictions.
In Act III, Scene 2, Hamlet says he holds his friend “in my heart of heart” and next, when the Players perform, Horatio helps Hamlet observe Claudius. At the end, as Hamlet lays mortally wounded, Horatio first offers to kill himself from grief but then promises Hamlet he will not, but will instead stay alive and tell the world about the events at Elsinore. The initial emotional reaction is the only real exception to his character’s rational personality but is consistent with his love for his friend.
Rosencrantz and Guildenstern come to visit Hamlet at Elsinore. He is immediately suspicious as they have been out of touch, and it turns out he was right because they really are there to spy on him for Claudius. They help him set up the Players’ performance, not suspecting he plans to use it to trap Claudius into confession. Before Hamlet leaves for England, he opens a letter and learns that rather than just accompany him, they have agreed to deliver him for execution. He switches the letter and escapes en route, so that the two treacherous spies are killed instead—information that emerges only at the end of Act V.
Although Claudius is actually king of Denmark, Horatio takes Hamlet’s side as Hamlet should have been his father’s heir and Claudius has usurped his position. While Claudius attempts to manipulate everyone around him, he does not succeed with Horatio.