My Webster's says that it dates from before the 12th century and comes from middle or old English alluding to the fact that some butterflies are attracted to buttermilk; ie the fly that is attracted to buttermilk. Mythology had it that witches took on this form to steal milk. The German word Schmetterling has a similar origin in that "Schmetten" means cream. There are also several old German dialect words, such as 'Milchdieb' (milk thief), which have the same connotation.
I prefer the English urban myth version which refers to the greenish-yellow coloured Brimstone butterfly, Gonepteryx rhamni, which is one of the first on the wing in the spring in Europe, and from which the name butter-coloured fly is derived.