“Smarty-pants” also means “know-it-all” but, to me, seems to imply someone who is more cheeky than obnoxious, especially since it is often used as a schoolyard taunt. Still, such people can be annoying if they’re always trying to one-up you.
“Smarty” has been used since at least the mid-1800s to put down some who was too smart for their own good. The Oxford English Dictionary says the term referred to a “would-be smart or witty person.”
In describing “smarty-pants” (US) and “smarty-boots” (UK), the OED gives their first citation as by Budd Schulberg in 1941, but the word was well established by that time.
A description of the type appeared in an Ohio newspaper in 1938: “But the Smarty Pants breed is peculiar to the 20th Century. Unlike the common garden variety of Swell Heads, the Smarty Pants is not happily content with grabbing the spotlight for himself — he must kick someone else in the shin while so doing. It is not enough to boost his own stock — he must simultaneously belittle the other fellow’s.”
Society bandleader and pianist Eddy Duchin brought out a record of that title in 1939, and “smarty-pants” also appeared in1937, in a Wisconsin newspaper article in which a coach is giving advice to a rookie football player. I would guess you might also find it in earlier radio dialogue and juvenile film series like “Our Gang.”
The “pants” part of the word is are almost irrelevant, except perhaps to give the tone of talking down to a juvenile, or to emphasize the “smarty.” There are similar expressions, such as “fancy-pants” and “scaredy-pants.” Then again, perhaps “smarty” by itself was becoming over-used or boring.