Goats have rectangular pupils to increase the depth perception in their peripheral vision. The narrower the pupil, the greater the benefit, and round pupils, such as those in humans, can't narrow sufficiently to provide the same benefit.
Along with other prey animals, such as sheep and toads, goats need to be able to spot predators quickly and at a distance. Although there are other animals with rectangular pupils, goats have particularly light irises, which makes the pupil shape more striking. Goats' eyes are located on opposite sides of their heads to enlarge their field of vision to nearly 360 degrees.