Old English buttorfleoge, evidently butter (n.) + fly (n.), but of obscure signification. Perhaps based on the old notion that the insects (or witches disguised as butterflies) consume butter or milk that is left uncovered. Or, less creatively, simply because the pale yellow color of many species' wings suggests the color of butter. Another theory connects it to the color of the insect's excrement, based on Dutch cognate boterschijte. An overview of words for "butterfly" in various languages can be found here. Also see papillon.
Applied to persons from c.1600, originally in reference to vain and gaudy attire; by 1806 in reference to transformation from early lowly state; in reference to flitting tendencies by 1873. The swimming stroke so called from 1936. Butterflies "light stomach spasms caused by anxiety" is from 1908.