[This is a fast-access FAQ excerpt.]
This expression, meaning "be very careful to behave correctly",
has been in use from the 17th century on. Theories include: an
admonishment to children learning to write; an admonishment to
typesetters (who had to look at the letters reversed); an
admonishment to seamen not to soil their navy pea-jackets with
their tarred "queues" (pigtails); "mind your pints and quarts";
"mind your prices and quality"; "mind your pieds and queues"
(either feet and pigtails, or two dancing figures that had to be
accurately performed); the substitution of /p/ for "qu" /kw/ in the
speech of uneducated ancient Romans; or the confusion by students
learning both Latin and Ancient Greek of such cognates as pente
and quintus. And yes, we've heard the joke about the instruction
to new sextons: "Mind your keys and pews."
The most plausible explanation is the one given in the latest
edition of Collins English Dictionary: an alteration of "Mind
your 'please's and 'thank you's".