Like a pig in a wig [duplicate]

Solution 1:

The earliest Google Books match for "pig in a wig" is from "Precocious Piggy," in Home Songs for Little Darlings (1859):

Where are you going to, you little pig? / "I'm going to the barber's to buy me a wig." / A wig little pig! / A pig in a wig ! / Why, who ever before saw a pig in a wig?

The expression does not seem to be proverbial. In fact, the "pig in a wig" verse of the poem follows previous verses involving rhymes with big ("so young, so big!", dig ("a little pig dig!"), gig ("a pig in a gig!"), swig ("a pig have a swig!"), jig ("a pig dance a jig!"), and rig ("a pig run a rig!"), and preceding a verse involving a rhyme with twig ("hop the twig!"). The only surprise is that the little pig doesn't also dry a fig and vote for a Whig.

As Old Brixtonian notes in a comment beneath the posted question, children's rhymes often present nonsense juxtapositions purely on the basis of their involving two rhyming nouns. Dr. Seuss's Fox in Socks is a relatively recent example of this phenomenon, but I imagine that it goes back centuries. A thumbnail review of Fritz Eichenberg, Ape in a Cape: An Alphabet of Odd Animals in Quarterly Bulletin: Books for Children (1955) offers additional several examples:

A skilled artist represents each letter of the alphabet by a bold and lively drawing of an animal with a brief rhyming caption, such as "mouse in a blouse, pig in a wig, toad on the road, whale in a gale.

Although these nonsense verse references to a pig in a wig refer literally to a pig wearing or planning to buy a wig, the expression has been used figuratively (and insultingly) in instances that antedate the one in Harry Potter and the Philosopher's Stone. For example, from Eden Phillipotts, Ghostwater (1941) [combined snippets]:

I listened to every minute of the trial and if I'd guessed you were going to lose, I'd have come to you a lot sooner; but I never did guess it. The other chap—that fat pig in a wig that worked to hang Lamb—was out to beat you if he could. He weren't there for truth, nor justice, nor anything like that. He wanted to score off you. He didn't care two pence for Lamb's life and he worked like hell to block you and make you look foolish. But the dishonest blighter knew how to get round the jury all right. He appealed to their heads and you appealed to their hearts , and you could see the clash in their chapfallen mugs when they brought in their verdict and tagged the plea for mercy to to it, because they wanted to run with the hare and hunt with the hounds. Like we all do for that matter. ...

In this instance, the wig is literal, but the pig wearing it is the prosecuting barrister.

In Harry Potter and the Philosopher's Stone, the comment that "Harry often said that Dudley looked like a pig in a wig" indicates first that Dudley was quite overweight and in other respects (such as greediness and selfishness) piggish, and second that his haircut—presumably featuring long curly locks in the Little Lord Fauntleroy tradition (se the cover illustration in this edition of that book)—looked unflatteringly absurd when juxtaposed with his face and physique.