The pupil is the gap in the eye’s iris that allows light through to the retina. The muscles of the iris vary the pupil’s size, altering the amount of light that can get through. Our pupils are circular because the muscles are arranged in a ring that contracts evenly towards the centre. This has the advantage of giving even focus across the entire field of view, but circular pupils aren’t able to constrict as tightly as other pupil shapes.
Animals that hunt – or are hunted – at night need large, sensitive eyes that would be overwhelmed in bright daylight, so they have evolved an extra set of muscles to pull the pupil into a narrow slit shape during the day.
A 2015 study at the University of California, Berkeley, concluded that the evolutionary choice between vertical and horizontal slit pupils comes down to whether you are predator or prey. Predatory animals with vertical slit pupils, like cats and many snakes, can maintain sharp focus across the horizontal field of view and more accurately judge distance to their prey.
Horizontal slit pupils, on the other hand, sacrifice image sharpness at the left and right edges in return for wider peripheral vision. This gives prey animals such as horses and sheep a better chance of spotting predators.
Some animals have evolved even more elaborate shapes. Cuttlefish have a W-shaped pupil that helps to balance the bright light from above with the darker levels below. Some geckos have pupils that constrict to resemble a vertical string of pearls. This may have evolved to allow them to judge distance even without focusing both eyes in the same direction, by comparing the blurring at different pupil apertures.