In Shakespeare's Hamlet, the opening scene of the play provides the traditional exposition necessary in an Elizabethan drama, but also serves, interestingly, as, of all things, a transition: a transition from what has occurred in the past, to what will occur in the near future.
Exposition always does this to a certain extent, but Shakespeare manages to pack a great deal of information into his exposition.
The scene seems to begin in medias res (Latin for in the middle of things), not in the usual sense of beginning the story as near to the end of the entire story as possible, but in the sense that it begins close to what really matters in the opening of the drama: Hamlet meeting with the Ghost and being told that his father was murdered, and, therefore, did not die of natural causes and needs to be revenged. That, of course, is what the opening scene leads up to, although it does not occur until the fourth scene of the play.
Since Elizabethan drama uses no lighting or sets, the audience must quickly be informed of details we take for granted today. Bernardo's opening line,
for instance, depending on how it's performed, may establish that it is nighttime--if Bernardo has to ask because he can't see who it is, even though he's standing near the person, then it must be dark out. A few lines later the audience is informed that it is twelve, which would then mean midnight--the traditional witching hour, when spirits and ghosts roam the earth. And it is "bitter cold" says Francisco. And when Bernardo asks if Francisco has had a "quiet guard," the audience is informed, with certainty, that these are guards on watch.
Once the setting is established, then the real business is revealed. This scene presents the middle of three appearances by the Ghost. The first appearance was witnessed only by the guards. They have brought a well-respected man, considered a scholar, and a friend of Hamlet's, with them to verify what they see. That Horatio is a friend of Hamlet is vital, because the Ghost appears to be Hamlet's father, the dead King Hamlet. Thus, Horatio is present to lend legitimacy to what the guards have previously seen, and also, in the future (if the Ghost appears again this night), to provide a connection to someone who has the authority and power to really do something concerning the Ghost's appearances. (Again, this opening scene points backward to what has already occurred, and forward, to what will occur.)
And that is what happens. Notice the Ghost does not speak in either of these first two appearances--the visitations are incomplete. Neither the characters nor the audience knows why the Ghost is appearing. Suspense and anticipation are created, and what is introduced in scene one, must be concluded later, in scene four.
Incidentally, Francisco's reply that nothing of note has happened during his watch, that there was "Not a mouse stirring," will prove ironic later in the play. When Hamlet arranges for the "play within the play" to be performed so that he can determine for sure whether or not Claudius is guilty, and Claudius asks him what the title of the play is, Hamlet tells him "The Mousetrap." Mice will not prove to be so quiet later.