Why does Shakespere show such a scene at the beginning of Hamlet?
I am going to assume that you are referring to Act 1 scene 1. The reason that Shakespeare starts the play with several minor characters, rather than the main protagonist, Hamlet, is because he wants to establish the background information of the story that will follow, and because he wants to set the tone and mood for the rest of the story. You also have to remember that in Shakespeare's open-air theatre, there would be no way to signal the start of the play except for having the play itself begin. The first several lines of the play are never VITAL, as the audience would have just been settling into silence to hear the rest of the play.
The content of the opening scene is immediately intriguing -- after all, how many people have seen a ghost? The audience is immediately drawn in and starts to question why a ghost is appearing in the first place. Through the guards conversation with Horatio, we learn that the ghost looks like the recently deceased King Hamlet and we learn that this ghost doesn't seem to want to talk to any of these men, so he must be signalling that he wants to speak to someone else, probably his son, Hamlet. Horatio also reveals all of the possible reasons a ghost may appear: unfinished business, a warning, or to reveal hidden treasure. This gets the audience thinking about what could be THIS ghost's mission.
The second purpose of the scene is reveal the background of a military threat being posed by Fortinbras, Prince of Norway, whom we learn is planning an attack on Denmark to regain land lost be his father several years earlier. The guards ask about the increase in military preparations, so we learn that the current king is doing his job in protecting Denmark. We also learn a little about Fortinbras's nature. Horatio points out that he is "hot" and of "unimproved mettle" suggesting that he is a bit of a hot head and very determined. He also reveals that Fortinbras's army is made up of mercenaries, not the official army of Norway, again suggesting that Fortinbras is going to do whatever it takes to achieve his goals.
The audience clearly understands by the end of the first scene that there is potential internal and external problems for Denmark. We are now drawn into these mysteries and are anxious to see how everything resolves itself.
In the opening scene of Hamlet is under an atmosphere of suspense and fear, darkness and gloom, and prepares the mind of the audience for the appearance of the mysterious and unknown. It strikes the keynote of the play. There is an uncanny sees of fear and a feeling of uncertainty in the exchange of words between Francisco and Bernardo. The dead silence and the bitter cold make Francisco ' sick at heart '. When Horatio and Marcellus, the 'rivals' of his watch, join Bernardo, they make anxious enquiries about the dreaded sight and apparition which had already appeared twice. All these hushed whispers in cold and dark midnight create the proper atmosphere for the advent of the sceptic Horatio dumbfound. He frankly confesses that it harrows him with fear and wonder. He summons up courage to question the ghost, but it vanishes.
They now speak about the state of uncertainty and imminent fear that pervaded the entire state of Denmark. The suggestion is that the king's spirit has come to give warning about the future danger. The ghost appears again and Horatio asks :
Speak to me:
If thou art privy to thy country's fate,
Which, happily, foreknowing may avoid,
O, speak !
(act 1, scene -1)
But as the cock crows, the ghost disappears again. The entire scene has been written with a view to making the Ghost credible and convincing to the audience. It breathes an atmosphere of supernatural thrill and mystery and portends dark omens for the future.