The first apparition of the word "mariposa" is in Libro del cavallero et del escudero
by Infante Don Juan Manuel (1326).
The most accepted etymology comes from Joan Coromines, in his Diccionario crítico etimológico castellano e hispánico
: "mariposa" comes from the expression "Mari, posa(te)" (Mary, alight!), present in children's songs and games. In Sardinian and dialectal French, there are several similar words ("maria vola") to say "butterfly".
Vicente García de Diego (just as Sebastián de Covarrubias in Tesoro de la lengua castellana o española
, 1611) thinks that "mariposa" comes from the Latin "male pausat" (bad alighted); and for the Sardinian form, he thinks that it comes from the Latin "mane et pausat".
RAE (Real Academia Española de la Lengua), in its dictionary (DRAE), offers Coromines's theory.
The use of personal names for animals is not unusual in Romance languages: mariquita (ladybird in Spanish) and marieta (ladybird in Catalan) come from nicknames of Maria, guilla (fox in Catalan) comes from a nickname of Wilhelmina, renard (fox in French) comes from Reginhard, etc., etc.