What does the phrase "mind your 'p's' and 'q's'" come from?
You can find helpful answers to questions like this in the alt.usage.english FAQ.
According to the FAQ, there are several theories about how the expression, which means "to be careful to behave correctly," was first used.
There are other theories but as the FAQ points out, the most plausible might be the explanation given by the Collins English Dictionary. The CED says that it is an alteration of the expression, "mind your please's and thank you's."
—The Fact Monster