In order to keep from shriveling like your fingers in the bathtub, fish must constantly exchange ions, such as sodium and potassium, with the water. Larval fish can exchange ions through their skin, and early fish likely used rudimentary gill structures known as branchial baskets. But when the salinity of the water changes rapidly--as happened when fish invaded freshwater habitats--fish would have needed a much more efficient way of exchanging ions with their environment. That means large, complex gills.
Link via reddit | Photo: US Department of the Interior