1605, common European bird, known for its chattering, earlier simply pie;
first element from Mag,
nickname for Margaret,
long used in Eng. proverbial and slang senses for qualities associated generally with women, especially in this case "idle chattering" (cf. Magge tales
"tall tales, nonsense," c.1410; also Fr. margot
"magpie," from Margot,
pet form of Marguerite
). Second element, pie,
is the earlier name of the bird, from O.Fr. pie,
from L. pica
"magpie," fem. of picus
"woodpecker," possibly from PIE base *pi-,
denoting pointedness, of the beak, perhaps, but the magpie also has a long, pointed tail. The birds are proverbial for pilfering and hoarding, can be taught to speak, and have been regarded since the Middle Ages as a bird of ill omen.
"Whan pyes chatter vpon a house it is a sygne of ryghte euyll tydynges." 
Divination by number of magpies is attested from c.1780 in Lincolnshire; the rhyme varies from place to place, the only consistency being that one is bad, two are good.