The theme suggested by this entire "crazy" conversation by Hamlet is theme of disease and decay in the state of Denmark. As he has done before, Hamlet is putting on a show of insanity, but his comments are pointed and meaningful. In this scene, Hamlet is taunting Claudius with the knowledge of the whereabouts of Polonius's corpse. Hamlet tells the court that Polonius is now "worm food." He then goes on to explain that a worm could be used by beggar in order to a catch a fish. If that beggar then eats that fish, then by a logical process of digestion, the worm (that fed on the dead corpse) will eventually be excrement of the beggar. If this is true for Polonius, it is true of all humans -- even a king. Hamlet is specifically trying to be rude and crass about Claudius -- the very idea of the conversation is highly insulting! But Hamlet has spoken of the disease and decay and the things that are rotten in the state of Denmark, and ultimately, he is trying to rid the throne of that "murderous and adulterate beast" that is Claudius.
In Shakespeare's Hamlet, there are a great many word games. Hamlet is pretending to be mad and trying to throw off his enemies, primarily Claudius, and incidentally the spying Polonius. Sometimes he says nonsensical things. However, as foolish as Polonius is, Shakespeare, ironically, uses the old man to speak words of great wisdom (as seen when he gives "life advice" to Laertes). Polonius watches Hamlet carefully and notes that there seems to be some sense in his insanity.
[Aside] Though this be madness, yet there is method in't. (II.ii.210-211)
Hamlet plays these games when the King and his men try to find Polonius' body. Here Hamlet puts life and death into perspective, stating that in death, everyone is equal. He is saying that a King can be reduced the status of a beggar in death, and he may be motivated to say this based, finally, on his realization that Claudius is guilty of murdering a king, Hamlet now has proof, and that Claudius dies as has Old Hamlet with God's blessing.
In some ways it's almost paradoxical that Hamlet can place king and beggar on the same level, after his earlier praise of mankind, but he has changed seeing life through the eyes of his murdered father:
What a piece of work is a man! how / Noble in
Reason! how infinite in faculty! in form and / moving
how express and admirable! in Action, how like an / Angel! ...how like a God?...and yet to me, what is
this / quintessence of dust? Man delights not me... (II.ii.303-307)
Hamlet places a king and a beggar on the same level or "plate." The remains of each are equal, "two dishes, but to one table." He discusses how the remains of a king, eaten by the worm, and the worm by the fish, may be food for a peasant, alluding to the theme that death is the "great equalizer." And because this is a revenge play, his hidden reference to Claudius' impending death, will end not only the King's life, but his aspirations of power. When Claudius killed Old Hamlet, Hamlet's uncle forfeited his life—but he will also lose his throne and his sense of his own importance: it is for this power that Claudius committed the murder. Hamlet is now convinced he is morally obligated and righteously motivated to take the King's life.
Your fat king and your lean beggar is but variable service, two dishes, but to one table. That's the end....A man may fish with the worm that hath eat of a king, and eat of the fish that hath fed of that worm... (IV.iii.26-28, 30-31)
The themes I see here are "death as the great equalizer," driven by the theme of Hamlet's ultimate act of revenge for his father's death.