Mrs. Baker uses the quote to let Holling know that she has forgiven him for ruining the cream puffs with dust from the chalkboard erasers.
By using the quote, Mrs. Baker also manages to extend a little comfort to Holling. It is her way of reassuring Holling that she understands his actions were unintentional.
The quote also explains why Mrs. Baker purchases 24 cream puffs for Holling and his fellow students. In the story, Holling must acquire two dozen cream puffs after his classmates (Meryl Lee, Danny Hupfer, Mai Thi, and Doug Swieteck) threaten him with physical violence for supposedly depriving them of the delicious treats.
Holling does purchase the cream puffs. However, no one gets to partake of them. After recess, the children find Sycorax and Caliban (rats that were former class pets) devouring the sweet treats. Now, Holling's classmates give him 10 days to come up with another fresh batch of cream puffs.
Of course, Holling doesn't have the financial means to purchase another dozen cream puffs. He asks his father for an advance on his allowance and is cynically rebuffed. In the end, it is Mrs. Baker who comes through for Holling. After the children enjoy the cream puffs, Holling thanks Mrs. Baker privately for her generosity. This is when she quotes the famous words from the Merchant of Venice. By quoting the words, Mrs. Baker is letting Holling know that she understood his predicament, had pity on him, and purchased the dozen cream puffs as a gracious favor.