Originally, zoos were created just to show off exotic animals to the public (before this only royalty and other rich people kept 'menageries' of wild animals). Today, the main function of zoos is conservation. Without captive breeding, many endangered species would now be extinct - for example, the golden lion tamarin, red wolf and Przewalski's horse. I am not for a moment suggesting that we should stop trying to protect animals' natural habitats, but if endangered species were to become extinct in the wild (which sadly seems quite likely in the near future), zoos will have preserved them for future generations, with enough genetic diversity that the possibility for reintroduction to the wild exists.
Zoos are also vital for education, enabling people to see beautiful wild animals that they would never otherwise get to see, and teaching them about the threats to their species, which hopefully encourages them to respect and protect animals. The money they bring in is used to pay for the animals' food and care and to fund breeding programmes, as well as the employees' wages. Some also goes towards funding the protection of animals in the wild, and their habitats.