The idiom is apparently derived from a centuries - old Scottish proverb, though some other references to pigs flying or pigs with wings are more famous. At least one appears in the works of Lewis Carroll:
where does the expression when pigs fly come from
a centuries - old Scottish proverb