The overwhelming majority of life on our planet depends on the sun for energy. Because life is so tightly linked to the sun, it is no surprise that many organisms (excluding those that live in total darkness) have evolved the ability to detect and respond to light. Plants turn their leaves toward the sun. Single-celled algae, protists, and other microbes swim toward or away from light. But it is the animals, with our image-forming eyes, that have taken light detection to the next level.
96% of animal species have eyes. The first animal eyes did little but detect light—they helped to establish day/night cycles and coordinate behavior—but more-complex eyes soon evolved. A predator who can see its prey from a distance, or a prey animal that can see the shadow of a predator approaching, has a clear survival advantage over those who can't. Even a slight improvement in image quality provides a significant survival advantage, allowing for the step-by-step evolution of increasingly complex eyes.