I don’t see anything magical about the eye…
As others point out - start with alight-sensitive spot.
A lot of evolution consists of accidental doubling and re-doubling of genetic instructions. We still get the occasional sixth finger or sixth toe instance… Crustacea like lobsters, or even insects, are a great example. Start with a simple organism, double up, double up again, to get multiple segments - eventually specific segments evolve specialized limbs for specific tasks. So one light sensitive spot becomes two or more… If they are in an indent, then this assists in determining directionality - another advantage.
When I was particularly badly sunburned (or stove-burned) I got blisters, which were water-filled blobs under my surface layer of skin. It’s not hard to imagine this as a logical evolution of “how does the body protect the critical light-sensitive spots?” The organisms whose eye coverings best shape like the appropriate lens have sharper vision, a survival attribute.
the ability to move the top of this light-sensitive pit gives a bit more precision to the evolving vision. So just as you can wiggle your nose or ears, or smile, the muscles that can move the “eyehole” can significantly improve ability to quickly change direction of view, without moving the whole body. Some more primitive animals have eyes on stalks, but a critical survival capacity means the eye should be less vulnerable, should not stick out. So an eyehole that can be moved internally gives an advantage; so imagine an animal can point the eye pit sort of like how you can wiggle your nose to point your nostrils slightly one way or the other. Or… move your tongue inside your mouth to point where you want…
And of course, evolution likes to take a good idea and run with it. Eventually an aimable pit lined with light sensitive nerves becomes a more rounded ball-like structure with far greater ability to aim. more than one light-sensitive spot becomes tens of thousands.
And of course, the neural networks in the brain that interpret the images have evolved with the quality of the eyes… from simple “am I in the light or hidden?” to recognizing familiar shapes and analyzing what is seen.
There are dozens of other “design” decisions that evolution has made. The closer the eyes are to the brain, the shorter the nerve connection, the less likely an accident will cause blindness; if your eyes were in your fingers, any bad accident could damage them and make you blind, a severe evolutionary disadvantage. It’s a lot easier to get by with a few fingers missing than to go blind. Eye placement evolves according to need - horses or chickens that need to see enemies coming in any direction have eyes that cover 360 degrees; animals that jump form tree to tree or onto their prey have better advantages with depth perception provided by side-by-side eyes… and so on.