worm (n.) Look up worm at Dictionary.com
Old English wurm, variant of wyrm "serpent, snake, dragon, reptile," also in later Old English "earthworm," from Proto-Germanic *wurmiz (source also of Old Saxon, Old High German, German wurm, Old Frisian and Dutch worm, Old Norse ormr, Gothic waurms "serpent, worm"), from PIE *wrmi- "worm" (source also of Greek rhomos, Latin vermis "worm," Old Russian vermie "insects," Lithuanian varmas "insect, gnat"), probably from root *wer- (3) "turn" (see versus).

The ancient category of these was much more extensive than the modern, scientific, one and included serpents, scorpions, maggots, and the supposed causes of certain diseases. For substitution of -o- for -u-, see come. As an insult meaning "abject, miserable person" it dates from Old English. Worms "any disease arising from the presence of parasitic worms" is from late Old English. Can of worms figurative for "difficult problem" is from 1951, from the literal can of worms a fisherman might bring with him, on the image of something all tangled up.
worm (v.) Look up worm at Dictionary.com
"to move like a worm," c. 1600, from worm (n.). In figurative senses attested from 1620s, suggesting patient, sinuous progress. Meaning "to free from worms" is from 1620s. Related: Wormed; worming.