In Shakespeare's Hamlet, the Prince of Denmark has just spoken to the ghost of his father, Old Hamlet. The Ghost has told Hamlet that he was murdered while he was taking his daily nap in the orchard, poisoned by his brother Claudius. The new king not only took Old Hamlet's life and his wife, but more than that, he sent him to death without a chance to cleanse his sins from his soul. He says:
As I was sleeping in my orchard,
Always my habit in the afternoon,
Your uncle sneaked in, when I didn’t have security near,
With juice of poisonous hebenon in a vial,
And poured the juice that causes white scales
Into the openings of my ears... (64-69)
So I was, sleeping, by a brother's hand,
Gotten rid of, deprived of life, of crown, of queen,.
Cut down even without forgiveness for my sins,
No last Communion, unprepared, no last anointing,
No accounting made, but sent to my account
With all my imperfections on my head. (79-84)
Hamlet's father wants Hamlet to exact revenge for his death. When Hamlet returns to the others, they (of course) ask what the Ghost had to say. It is at this point that Hamlet decides to keep what he knows a secret.
When Horatio and Marcellus ask him for news from the Ghost, Hamlet pretends to be secretive and asks them if they can keep a secret. They agree, and Hamlet says:
There's ne'er a villain dwelling in all Denmark
But he's an arrant knave. (134-135)
Hamlet is stating the obvious: that every villain in Denmark is a scoundrel (a crook; someone dishonest—"arrant" means outright, complete, or total). So he is saying that every bad guy is a total crook. The men react as you might expect—"we don't need a ghost to tell us that:"
There needs no ghost, my lord, come from the
To tell us this. (136-138)
This curious behavior is simply foreshadowing the kind of behavior we can expect from Hamlet when he acts crazy...puts on an "antic disposition." Hamlet is not referring to himself with this quote, but he is thinking that Claudius is a villain.