Shakespeare, as other Elizabethan writers, uses the idea of ghosts in his plays usually as a foreshadowing of events to come. In "Hamlet," Hamlet has to deal with working out what to do with his father's request for revenge, and also, whether the ghost is indeed his father. In "Macbeth", Macbeth has to deal with the Ghost of Banquo showing up to dinner, literally haunting him. In "Richard III", Richard deals with the ghosts of the men he has wronged right at the start of the play.
This haunting is significant also in "Julius Caesar". The Ghost of Julius arrives on the eve of battle to literally haunt Brutus. Brutus had hoped that by killing Caesar he would enact change in Rome, however, the Roman Empire goes on, as does the reign of Caesar (albeit, a new Caesar).
As Brutus goes into battle, and the battle doesn't go his way, he again turns to Julius Caesar, blaming him for the outcome of the battle,
O Julius Caesar, thou art mighty yet!
Thy spirit walks abroad, and turns our swords
In our own proper entrails. (5.3.94–96)
Shakespeare's ghosts are visible to one person (as well as the audience, clearly) so those who react to the ghost are the ones who are supposed to learn from the arrival of the ghost, heeding the message from beyond the grave.
Enter the Ghost of CAESAR
How ill this taper burns! Ha! who comes here?
I think it is the weakness of mine eyes
That shapes this monstrous apparition.
It comes upon me. Art thou any thing?
Art thou some god, some angel, or some devil,
That makest my blood cold and my hair to stare?
Speak to me what thou art.
Thy evil spirit, Brutus.
Why comest thou?
To tell thee thou shalt see me at Philippi.
Well; then I shall see thee again?
Ay, at Philippi.
Why, I will see thee at Philippi, then.
Looking at the entire interaction, Brutus first of all questions who the ghost is, but as soon as the ghost calls him an evil spirit, he knows who it is. The ghost of Julius Caesar answers his question twice, that he will see him at Phillippi.
Brutus is now aware that death awaits him at Phillippi, and on the other side, Julius Caesar is also awaiting Brutus for his actions. The haunting of Brutus sets up his eventual demise, foreshadowing to the audience and reader alike that the end is nigh for him, allowing the tragic element to come full circle. When the ghost again appears on the battlefield, Brutus accepts his demise and becomes a tragic hero, urging the ghost of Caesar to be at peace as Brutus takes his own life.
Runs on his sword
Caesar, now be still:
I kill'd not thee with half so good a will.