"How all occasions do inform against me," remarks Hamlet in his final soliloquy, and, certainly, the visit of his boyhood friends, Guildenstern and Rosencrantz underscore this observaion of the Prince of Denmark regarding the terrible corruption of the court of Denmark. Toadies, Rosencrantz and Guildenstern seek to ingratiate themselves with Claudius, perhaps hoping for political favors, so they carry out his wish to learn what they can about Hamlet.
Fearing Hamlet, Claudius hires the two men to learn what they can of Hamlet's recent actions, and to take him to England so that Hamlet can be killed; however, the perspicacious Hamlet realizes that they are no longer his friends, and he is circumspect with them when they ask what has become of Polonius:
Tell us where 'tis, that we may take it thence
And bear it to the chapel.
Do not believe it [Hamlet]
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? [Hamlet]
Take you me for a sponge, my lord?
Ay, sir, that soaks up the king's countenance, his rewards, his authorities. [Hamlet] (4.2.5-14)
That Hamlet speaks to the men in prose rather than verse which the aristocratic characters of Shakespeare use, also indicates Hamlet's low opinion of Rosencrantz and Guildenstern as obsequious sycophants.
In scene 2, Rosencrantz and Guildenstern try desparately to do as they are instructed by the king, while also trying to be friends to Hamlet. Unfortunately, their ultimate loyalty is to the King and his promised reward. Hamlet knows this and calls them out on it. Either they truly are too naive to understand what Hamlet says to them, or they are putting on an act to appease his crazy behavior -- maybe it is a mixture of both.
They have been instructed to find out from Hamlet where he has hidden Polonius's dead body, but Hamlet only toys with them, answering with a riddle of sorts that Polonius is "compounded . . .with dust." We later learn that Hamlet has stowed Polonius is a presumably dusty closet under the stairs.
Hamlet then directly calls them "sponges." Rosencrantz turns it back and questions if Hamlet really thinks he is a sponge. Can he really think that Hamlet is being literal -- even in his "crazy" mode? Hamlet clearly explains that they are LIKE sponges in that they soak up what the king wants, but then they will be wrung out as useless when Claudius is done with them. They clearly look like fools to us that know their whole story.
In scene 3 they can only report to Claudius that Hamlet won't tell them anything. They look like failures, but are still hedging around when they suggest that Hamlet is "guarded, to know [the King's] pleasure." Hamlet, in actuality, couldn't care less what the King's pleasures are. He has no intention of making this easy for anyone. Ros and Guil are shown to be looking out for themselves first and foremost.