If anyone is interested in the evolution of the eye,
here's a video clip that present a model on how such an evolution can happen.
Random mutations causes slightly different eye forms among a population, and natural selection favours those who have the most efficient eyes compared to their peers.