When Rosencrantz and Guildenstern eagerly accept king Claudius's appointment as his spies to snoop on Hamlet and persuade him to do the king's bidding, they clearly show where their loyalties lie. They are, obviously, not so much interested in their friend's well-being as in the material and other rewards their acquiescence to Claudius's request will bring.
In this encounter, Hamlet makes his sentiments clear. He does not trust either of them and directly states his suspicions when he tells Rosencrantz that he is "a sponge." At Rosencrantz's question of why he calls him this, Hamlet explains,
Ay, sir, that soaks up the king's countenance, his
rewards, his authorities. But such officers do the
king best service in the end: he keeps them, like
an ape, in the corner of his jaw; first mouthed, to
be last swallowed: when he needs what you have
gleaned, it is but squeezing you, and, sponge, you
shall be dry again.
Hamlet is essentially calling Rosencrantz the king's lackey who has gained his approval. He tells him that, like a sponge, he has taken in whatever benefits the king has extended him and that he has also been drawn in by the king's authority. Hamlet makes it clear that it is individuals such as Rosencrantz -- and by implication Guildenstern -- that show the king the greatest servility. Claudius can do whatever he wants with them. They are the types who the king uses at first and finally get rid of. Hamlet extends the metaphor by saying that the king squeezes whatever he needs out of them and once he has done this, they are back where they started.
Hamlet is clearly insulting. He suggests that Rosencrantz is "an ape," unintelligent and sycophantic, an object for the king's use. Rosencrantz knows exactly what Hamlet is about, but acts as if he does not understand. Hamlet's retort in which he states that such a devilish speech (as the one he has just made) cannot be grasped by a fool is another insult.
The two men pay for their indiscretion with their lives later in the play, when Hamlet outwits them and they are doomed for execution by the English king.
In Act IV, Scene II of Hamlet, Rosencrantz and Guildenstern, two childhood friends of Hamlet, are working with King Claudius against the Prince. They come to Hamlet asking for Polonius's body:
Do not believe it.
That I can keep your counsel and not mine own.
Besides, to be demanded of a sponge! what
replication should be made by the son of a king?
Take you me for a sponge, my lord?
Ay, sir, that soaks up the king's countenance, his rewards, his authorities. But such officers do the king best service in the end: he keeps them, like an ape, in the corner of his jaw; first mouthed, to be last swallowed: when he needs what you have gleaned, it is but squeezing you, and, sponge, you
shall be dry again.
By referring to Rosencrantz as a sponge, Hamlet makes it clear that he is suspicious of his friend. He believes that Rosencrantz is an opportunist, and is eager to ally himself with King Claudius. Like a sponge, he wants to soak up all the benefits of being in subservience to someone with great power. Hamlet suggests, however, that once Claudius is through with him Rosencrantz will simply be "wrung out to dry."