What is the significance of appearace of the ghost in Hamlet?
Whenever ghosts, spirits, and other elements of the celestial or occult sphere appear in Shakespeare, you know things are unnatural and out of order. The ghost appearing in Hamlet is ocular proof that "something is rotten in the state of Denmark". In Shakespeare's cosmology, Angels and spirits which descend the chain of being to speak to men below suggest disorder and an interruption of the natural order. Killing a king, regicide, is very much an unnatural thing because in the great chain of being, Kings are the apex of men.
The King's ghost walks in the night!!! Woooooah!
Remember, this play was written 400 years ago, before science and modern information. Many people were very superstitious and believed in ghosts and spirits and demons and allsorts of frightening goblins and monsters. They would have been genuinely frightened of places like, graveyards at night or wild forests because they thought these places were haunted. So a ghost in a play would have been a tense and exciting dramatic device. The audience would have been spooked and thrilled by it. It is like a scene from a terrifying horror movie.
Hamlets father's ghost is walking about on the castle battlements at night. The castle is haunted by the troubled spirit of the recently dead king! They believed that people who died in a bad way or died with some important information could not rest until it was sorted. A ghost was an unhappy, trapped spirit who couldn't travel to the next world until something was sorted out. So the ghost of a king represents the possibility very serious unrest.
If a peasant farmer's ghost walks the night, maybe it's because someone stole his pig or killed his dog. It is not a big issue. But if a king's ghost will not rest, the reasons could be very serious.