The play begins with an extended bit of metadrama; the company's stage-keeper enters, criticising the play about to be performed because it lacks romantic and fabulous elements. He is then pushed from the stage by the book-keeper, who (serving as prologue) announces a contract between author and audience. The contract appears to itemise Jonson's discontentment with his audiences: Members are not to find political satire where none is intended; they are not to take as oaths such innocuous phrases as "God quit you"; they are not to "censure by contagion," but must exercise their own judgment; moreover, they are allowed to judge only in proportion to the price of their ticket. Perhaps most important, they agree not to expect a throwback to the sword-and-buckler age of Smithfield, for Jonson has given them a picture of the present and unromantic state of the fair.
The play proper begins with a proctor and amateur dramatist Littlewit and his friends, Quarlous and Winwife; they are plotting how to win Dame Purecraft (a widow, and Littlewit's mother-in-law) from Zeal-of-the-Land Busy, a canting, hypocritical Puritan.
This colloquy is interrupted by the entrance of Wasp, the irascible servant of Cokes, a country simpleton who is in town to marry Grace Wellborn. Grace is the ward of Adam Overdo, a Justice of the Peace; Overdo's wife is Cokes's sister. All of these characters are at Littlewit's to get a marriage license; having obtained it, they indulge Cokes's wish to visit the fair.
Littlewit and his friends also plan to go to the fair to see a puppet-show Littlewit wrote. To overcome Busy's likely objections, they pretend that Win (Littlewit's wife) has a pregnant craving for roast pork. The Renaissance audience, familiar with stage satire of Puritans, would not have been surprised that Busy, far from abhorring the fair and its debauchery, is ready to rationalise his presence there as allowable and even godly. The first act ends with both groups, the genteel Overdos and the raffish Littlewits, headed for the fair.
The fair propels these characters through experiences that put their social identities under extreme strain. Justice Overdo, well-read in the "disguised prince" tradition, assumes a disguise to ferret out wrongdoing at the fair; he is beaten by Wasp, falsely accused by Edgeworth, a cut-purse, and put in the stocks. Quarlous and Winwife engage Edgeworth to steal the marriage license from Wasp; he does so when Wasp is arrested after starting a fight. Wasp, too, is put in the stocks. Winwife has abandoned his plan to marry Dame Purecraft; instead, he and Quarlous fight for Grace's hand. Win Littlewit and Mistress Overdo are enlisted as prostitutes by the pimp Whit; Zeal-of-the-land Busy is arrested for preaching without license and put into the stocks. Cokes is robbed several times by Edgeworth and other denizens of the fair. All the imprisoned characters escape when Trouble-All, a seeming madman for whom Dame Purecraft has conceived a sudden passion, fights with the guards.
The climax of the play occurs at the puppet show. Madame Overdo and Win are brought in, masked, as prostitutes; Madame Overdo is drunk. Overdo is still in disguise, and Quarlous has disguised himself as Trouble-All; in this guise, he stole the marriage license from Winwife and made it into a license for himself and Purecraft. The puppet show, a burlesque of Hero and Leander and Damon and Pythias, proceeds until Busy interrupts, claiming that the play is an abomination because the actors are cross-dressed. The puppets refute him decisively by raising their clothes, revealing that they have no sex. Busy announces himself converted into a "beholder" of plays.
At this point, Justice Overdo reveals himself, intent on uncovering the "enormities" he has witnessed at the fair. He is in the process of punishing all of the various schemers and malefactors when his wife (still veiled) throws up and begins to call for him. Abashed, Overdo takes the advice of Quarlous and forgives all parties; Winwife marries Grace, Quarlous marries Purecraft, and all the characters are invited to Overdo's house for supper.

Question: Why has Justice Overdo attended the fair in costume?
Answer: To conceal is identity so he can freely investigate the bad behavior he sees at the fair.
Alternative answer: So he could find wrongdoers.