The Ghost is one of the great mysteries of Hamlet. The play begins by showing us the Ghost appearing in front of several witnesses, who see it and discuss it among themselves, so we know from the outset that the Ghost is not simply a figment of Hamlet’s imagination. We also learn later in the play that the Ghost is telling the truth about being murdered by Claudius, because Claudius admits to the murder when he’s talking alone in Act 3, scene 3. However, the basic nature and intention of the Ghost remain mysterious. The Ghost claims that it is the spirit of Hamlet’s father, and that it currently spends most of its time in purgatory being purified before it can enter heaven, and that it has been released for a short time to deliver its message to Hamlet. This explanation doesn’t make a lot of sense, because the Ghost is a very dark and frightening creature, and it urges Hamlet toward vengeance, sending him down a path that leads to murder and his own destruction. Vengeance is not a heavenly virtue or Christian value, and heavenly beings don’t normally appear to tempt characters toward violent and tragic paths. (The Ghost is in purgatory not heaven, but presumably only a heavenly being would have the authority to release it. The Ghost may be unique in literature in claiming to be returning specifically from purgatory.)
Hamlet himself raises the possibility that the Ghost is actually a demon impersonating his father, which certainly seems possible, though we never see any further evidence to support this idea. In Act 3, scene 4, when the Ghost appears to Hamlet (and the audience) but not to Gertrude, Gertrude sees the Ghost as a sign of Hamlet’s madness. Because we’ve already seen that the Ghost can appear to other people and that it was right about Claudius, on a first viewing we would probably conclude that the Ghost simply chose to appear only to Hamlet and that Gertrude is mistaken about his being mad (even more so since Hamlet announced his intention to appear mad). However, in the context of Hamlet’s increasingly distraught emotional state, the Ghost’s appearance only to Hamlet seems more ambiguous. It may be a demon trying to make Hamlet insane, or a manifestation of Hamlet’s inner demons.