How do game publishers make profit?

To create a game, money so many wages have to be paid: monthly salaries for all the developers, designers, testers, project managers and so on, for multiple months, maybe years. The companies that do the programming and testing also need to spend a lot of money on the technologies (multiple consoles and performant PCs).

Let's say a publisher puts money for a game that is not a huge one. The game will get some purchases from its "fanbase" (which will be small since the game is not popular) and a few people will buy it in the first days after seeing the game on the first pages on Steam store. After a week or two, the game will probably not feature on any list from Steam, so it will be incredibly hard for other users to discover it. In the end, there will be a few hundred people buying the game, for like 20$.

How can game publishers make money if so many money is invested in video games and there's low probability that the investment will generate profit?