Pretending to be mad or insane, Hamlet plays with Polonius, saying to him:
For the satirical rogue says here that old men have gray beards, that their faces are wrinkled, their eyes purging thick amber and plum-tree gum, and that they have a plentiful lack of wit, together with most weak hams—all which, sir, though I most powerfully and potently believe ...
Hamlet's imagery alludes to a satirist who who mocks old age. He describes old age as a time of disease. Old men's eyes are running with mucus, as if they have an eye disease, they are senile or somehow have lost their mental powers, for they lack "wit," and their hams or buttocks are weak. Hamlet says he believes this description, and it may well be true that he does. To him, the whole world seems decaying and diseased because of what he has learned from the ghost.
Later, in trying, a bit satirically, to explain his depression to the courtiers, Rosencrantz and Guildenstern, Hamlet uses the imagery of disease to describe how the sky looks to him through his unhappy eyes:
this brave o'erhanging firmament, this majestical roof fretted with golden fire—why, it appears no other thing to me than a foul and pestilent congregation of vapors.
In other words, Hamlet knows objectively that the sky is "majestical" and filled with the golden light of the sun, but because he is so downcast and depressed it seems foul and "pestilent" (diseased.)
There are many references to death and decay throughout Hamlet, making it a motif of the play.
Act 2 begins with Polonius requesting that Reynaldo spy on his son in France, before Ophelia enters after a troubling encounter with Hamlet. While following Polonius’s instruction to reject Hamlet, the prince came to see Ophelia with his stockings down to the ankle and an overall disheveled look. In her account of Hamlet’s strange behavior during this meeting, Ophelia says:
At last, a little shaking of mine arm,
And thrice his head thus waving up and down,
He raised a sigh so piteous and profound
As it did seem to shatter all his bulk
And end his being. (2.1.104-08)
This references death and the decay of the body, suggesting that Hamlet convulsed and moaned like a death rattle.
Another reference to death and decay in act 2 comes when Polonius speaks to Hamlet after telling Claudius and Gertrude that Hamlet is mad with love for Ophelia. When he enters, Hamlet immediately begins acting insane, calling Polonius a fishmonger and making bizarre statements, including the following:
For if the sun breed maggots in a dead dog, being a good kissing carrion—Have you a daughter? (2.2.197-99)
This somewhat nonsensical quote is a reference to the natural decomposition process that begins after death. Hamlet is actually insinuating that Polonius is a rotten man with this reference to death. However, this goes completely over Polonius’s head, since he is too focused on Hamlet’s relationship with Ophelia to actually comprehend what Hamlet is saying.
The references to death throughout this act and the rest of the play generally foreshadow the tragic ending, as well as emphasize Hamlet’s focus on mortality.
The first example is in Act II, scene ii. Hamlet meets Polonius and Ophelia, and tells Polonius not to let his daughter go out in the sun because it breeds "maggots in a dead dog"(II, ii, l.179). Hamlet is suggesting that Ophelia being exposed to the world (i.e., him) will cause her to become tainted/corrupted/desecrated... like a decompsing dead animal.
In speaking with Rosencrantz and Guildenstern, Hamlet begins to build his perspective on meaning of the life that will come to a climax with his speech over Yorick's head in Act V. Her in Act II, however, he simply makes reference to the the earth and air around him as being "no other thing to me than a foul and pestilent congregation of vapours." Pestilent implying a diseased and dying world. He ends by stating that all his surroundings are the "quintessence of dust". Te be dust is to have decomposed fully.
Hamlet is the most introspective of Shakespeare's tragic heros, and possibly the most depressed. He sees decay and corruption only in the world around him, and struggles internally to find meaning for the actions of humans... but fails.