All animal eyes may have had a common origin: a proto-eye that could resolve something more than light from dark. Sophisticated optical systems seem to have appeared abruptly ~540 million years ago, in the Cambrian explosion of life forms.
Rapid eye evolution was dictated by competition between predators and prey. Good eyesight quickly became essential. As well as gross morphology, nimble innovation in fine-scale anatomy appeared during the Cambrian.
Eyes for vision arose independently in cnidarians (e.g., jellyfish), echinoderms (e.g., sea stars), cephalopods (e.g., squid), invertebrates (e.g., insects), and vertebrates. The last common ancestor of these divergent phyla may have had at most a photosensitive spot; or maybe not.