In Act 1, Scene 4, Hamlet, accompanied by Horatio and Marcellus, encounter the ghost of Hamlet's father, the previous king of Denmark. This is the same ghost that Horatio, Marcellus, and Bernardo saw in the first scene of the play.
In Act 1, Scene 4, the ghost beckons Hamlet to follow him and Hamlet agrees, despite the warnings of his friends.
Act 1, Scene 5 begins with a conversation between the ghost and Hamlet. The spirit of Hamlet's father tells him how he was killed and urges Hamlet to take revenge against Hamlet's uncle Claudius. Hamlet agrees to his father's wishes and the ghost disappears.
After this, Marcellus and Horatio appear and talk to Hamlet. During the course of their conversation, he tells them of his plan to pretend to be insane, a tactic that will help him to carry his revenge.
Here, as before, never, so help you mercy,
How strange or odd soe'er I bear myself,
As I perchance hereafter shall think meet
To put an antic disposition on,
That you, at such times seeing me, never shall,
With arms encumber'd thus, or this headshake,
Or by pronouncing of some doubtful phrase,
As 'Well, well, we know,' or 'We could, an if we would,'
Or 'If we list to speak,' or 'There be, an if they might,'
Or such ambiguous giving out, to note
That you know aught of me: this not to do,
So grace and mercy at your most need help you, Swear.