The first answer is right in that Horatio does come along because he has been told that the ghost has appeared. But I do not think it is exactly accurate to say that he tagged along to see what would happen.
Instead, I think it is more accurate to say that Marcellus has begged Horatio to come and see what is going on. Marcellus wants him to see for himself that there really is an apparition that has been appearing to the guards. Here is a passage that confirms what I am saying:
Horatio says ’tis but our fantasy And will not let belief take hold of him Touching this dreaded sight twice seen of us. Therefore I have entreated him along With us to watch the minutes of this night,
Drama is based on conflict. There is usually a big conflict going on throughout the story or novel or play, and also small conflicts in individual scenes. When Horatio joins Marcellus and Bernardo the three men are bickering about the ghost. Horatio thinks it can't be a ghost because there are no such things as ghosts. Marcellus and Bernardo thinks there must be ghosts because they have seen one. This adds a little spice to the scene. It seems natural that Horatio would join them on their watch if they tell him they have seen a ghost who looks exactly like the late King Hamlet. He might ridicule him, and then they might challenge him to come and see for himself. They expect the ghost to return because it has appeared several nights in succession. Otherwise, they couldn't promise him he would see the ghost.
Shakespeare wanted Horatio to report the visit of the ghost to Hamlet because Horatio is Hamlet's confidant throughout the play, right up to the very end. Horatio's report would be more reliable than that of Marcellus and Bernardo. Hamlet believes Horatio, but he probably wouldn't believe Marcellus and Bernardo any more than Horatio did before he saw the ghost with his own eyes. The audience only sees a bearded actor wearing armor and a helmet. Shakespeare has to take great pains to establish that (1) this is a ghost and not a live man, and (2) that the actor looks exactly like the dead King Hamlet. The only thing the actor can do to seem to be a ghost, since he isn't wearing a sheet and isn't covered with luminous paint, is to walk in a "ghostlike" manner. We can imagine that the actor would stalk slowly and silently. He would probably be wearing only stockings or felt slippers so that he wouldn't make the stomping sound that is heard so often in stage plays when actors walk across a wooden stage.
That would have been about as much as Shakespeare could hope to achieve--but a lot would depend upon the dialogue. All three men keep saying the actor in the armor and helmet is a ghost and looks exactly like the dead King Hamlet. Shakespeare wanted to establish this beyond doubt before Hamlet encounters the ghost of his dead father. Otherwise there would have to be a lot of dialogue between Hamlet and the ghost for the purpose of establishing the ghost's identity.
In a movie version of Hamlet it would be very easy to make the ghost look "ghostlike." They can do practically anything in a movie--but Shakespeare didn't have those technical options. In a movie the ghost could be transparent, luminous, and floating in air. Even his voice could be made "ghostlike" in one way or another.
Pohnpei397's answer summarizes the objective reason for Horatio's presence; he suspected the others of hallucinating and has been asked to "see for himself". However, in his subsequent dialogue it becomes clear that Horatio is also educated and bold, although this does not necessarily work in his favor.
Examples of this include Horatio's knowledge of ancient Rome, legends surrounding ghosts, and having the courage to actually speak to it. However, he is also foolish in that he commands the ghost, as well as suggesting to strike it with a weapon, both of which are useless pursuits particularly given that the ghost is that of a king.
It may be that Horatio is esteemed by his peers for his knowledge, and that there is a small element of bravado and bullying that makes him a leader too, albeit a lesser one, as demonstrated by his more subservient role throughout the rest of the play. Thus, they may have requested Horatio's presence because they value his knowledge, as well as to gain his approval, as he is esteemed among them, and is more accessible than an actual nobleman or higher ranking officer.
Horatio was informed that they'd seen the ghost of Hamlet's father before this night, and thus he tagged along to see what would happen this night.