The publishers usually survive because of the income generated by large bestsellers. This income is what pays for the books that end up not selling well. The vast majority of books don't sell much, so without the popular books, publishers can't afford to publish.
There are many publishers today whose whole operation is basically funded by two or three authors that sell really well. Those earnings offload the cost and losses of the other books.