What do flat characters like Polonius contribute to the plot of Hamlet?
Flat characters are simpler than round characters, which are more complex; one might be able to sum up a flat character in one or two sentences, but it would take a good deal more time to be able to accurately describe a round character. In addition, round characters tend to be dynamic, changing throughout the text, while flat characters often do not change, remaining static (this is not a rule but is a tendency). This is not a judgment on these characters—it's not as though flat characters are stupid; they are just defined by fewer qualities.
Flat characters like Polonius, Laertes, and Horatio can be reduced to just a few sentences or a couple of qualities but play pivotal roles in the play: if Polonius were not hiding behind the arras in Gertrude's room, Hamlet would not have slain him, and this action actually forces other necessary events to take place (Ophelia goes mad, and Laertes comes back to challenge his father's killer, which leads to the final duel in which he, Hamlet, Gertrude, and Claudius all die). If Laertes did not come back to Denmark and duel with Hamlet, the final excising of all that is rotten in the court could not occur. If Horatio were not there to be a sounding board for Hamlet, we would get many fewer indications of Hamlet's thoughts and feelings, he would lack an ally when he returns to Denmark, and there would be no one to tell the prince's story in the end.
It is somewhat of a misconception that fully rounded or developed characters are somehow better than flat characters. Actually, both have different purposes. A rounded character is important for literary works that are essentially psychological and where the main interest of the audience is the internal development or nature of a small group of characters. For other literary genres or emphases, such as moral conflict, plot development, and entertainment, flatter characterization can be as or more important.
Polonius is almostr a stock comic character who serves two purposes, plot development and comic relief. His character is that of a flatterer, who gravitates to power and who is constantly seen as currying favour. His death advances the plot of the play. In dialogue, he advances the discussion concerning Hamlet's madness:
Therefore, since brevity is the soul of wit
And tediousness the limbs and outward flourishes,
I will be brief. Your noble son is mad.