What does Hamlet mean when he says in Act 4, Scene 2, "I am glad of it: a knavish speech sleeps in a foolish ear"?
At this point in the play Hamlet has hidden Polonius' body and Rosencrantz (and Guildenstern and others) wants to know where it is so he can give him a proper burial. Hamlet is no fool and refuses to tell him where the body is. He proceeds to tell Rosencrantz (and Guildenstern and others) that he is a "sponge" to the king, he is basically saying that the king is using Rosencrantz and when his purpose has been served he will no longer find favor there. When he says this line "a knavish speech sleeps in a foolish ear" he is telling Rosencrantz that his good advice has been lost on his "friend's" stupidity and desire to be in the good graces of the king. The "knavish speech" speaks to is Hamlet's own insight to see the king for what he really is, decpetive and the "foolish ear" is speaking to Rosencrantz foolishness in trusting the king so blindly.
In Act Four, Scene 2, Hamlet hides Polonius's body, and Rosencrantz and Guildenstern ask him where the corpse is located. Hamlet refuses to give them a straight answer and calls Rosencrantz the king's sponge, who does Claudius's bidding and is squeezed out for information. When Rosencrantz responds by telling Hamlet that he doesn't understand what he is saying, Hamlet replies,
"I am glad of it. A knavish speech sleeps in a foolish ear" (Shakespeare, 4.2.22).
Hamlet is essentially telling Rosencrantz that he is glad Rosencrantz cannot understand what he is saying because fools cannot comprehend sly words. Hamlet knows that Rosencrantz is working for Claudius and is insulting Rosencrantz to his face by calling him a fool. After first refusing to give the two men a direct answer regarding the location of Polonius's body, Hamlet finally agrees to tell Claudius where he hid the body.