All decent zoos have, for more than half a century now, switched from the menageries and living collections that they were to spaces of conservation, research and education, greatly thanks to Gerald Durrell and the Jersey Zoo.
For this debate, zoos that do not comply with hygiene and security measures and that don't provide proper care for their animals should not be counted, because they are at a fault to start and are a really, really small number of zoos in developed countries. Most of these will get closed and the animals relocated.
If not for zoos, there are a lot of species that would be extinct now. IE the scimitar oryx, the milu, the Mexican wolf and the Przewalski's horse. All of these species extinct in the wild currently or previously with only individuals in zoos, private and public. Of these examples, the last Przewalski's horse sighted in the wild was in 1966 with 13 individuals in zoos. Breeding projects of these animals begun, some going to other zoos to start more breeding projects and research. From those 13 horses, there is now a wild population of at least 300 free ranging horses in their native Mongolia and over 1500 in captivity around the world. The largest breeding efforts are from a reserve in Ukraine and some were even released into the Chernobyl exclusion area, which is a de facto nature reserve now, with populations rapidly growing in number. There are breeding projects and reintroduction efforts for all of the species I mentioned above.
Now, to which is the flagship species of conservation, Pandas. Pandas are not extinct solely because of the interest people have in going to a zoo to see them. Almost all Pandas in every zoo are property of the Chinese government, with some exceptions like some at a Mexican zoo and at a Taiwanese zoo which were gifts, and are rented to zoos worldwide. It is of great profit to the Chinese government and it is because of that that they have the most successful panda breeding program in the world and many natural reserves dedicated to them. Pandas also work as an umbrella conservation species. Because of the interest in pandas, the bamboo forests and coniferous forests of central China are protected. Because of this, many other species that share the habitat are protected as well. This indirect help, added to the direct conservation efforts of some of these species has helped them stabilize their population or has at least made habitat loss the lesser of their problems. Some of the species that have benefited from this include the red panda and the snow leopard, whose main problem is now poaching. Even then, populations have been declining at a slower rate.
A lot of what is known about the biology of animals, that helps understand them for conservation efforts, are known from studying the animals in zoos. For example, quetzales, endangered and elusive, couldn't be kept in captivity until a couple of decades ago. All of the ones in captivity would die and no one was sure why, meanwhile the populations of wild ones kept dwindling and disappearing from parts of their natural range. It was until further examination conducted at an aviary that they realized they were getting poisoned by iron in the water. They have to be given almost distilled water, like the one they drink from bromelias in the wild, to drink. Now there are successful breeding programs that are reintroducing them to the wild. Quetzales were so elusive that little was known about them, like where they drank. It was the studies they were able to make to the individuals in captivity which let the investigators know this and save the species.
It is also completely absurd and fallacious (ad naturam) to think that an animal, by being in the wild, is happy by default or that captive animals are sad by default. In a (good) zoo, animals have a perfectly balanced diet, medical attention 24/7, clean environments and habitats with behavioral enrichment. They don't have to worry about anything and hormonal analysis of urine and blood prove it. It is true that the public may cause them stress, but well designed habitats allow them to expose themselves to the public only when they want to and they are not forced to leave their night houses if they don't want to. Wild animals in the other hand are in constant competition with other animals, they are full of parasites, they have to forage for food or hunt, defend themselves from predators, etc. It's not that they are unhappy, but their lives are considerably more stressful and they die much younger than their captive counterparts.
Shows are less common in zoos now as well. And unlike circus shows, most of the ones that still exist are made by positive reinforcement training. No animal is mistreated or doing things against their will.