Actually devs never make money directly from games
You have these people who do nothing of value called publishers who pay the devs to make a game, and then these publishers sell the game and take all money from it
In a sense, if a game doesn't sell well, publishers might not pay for those devs to make a game again, but that's it.
Capitalism is kind of fucking retarded in that it works based on "investors" supplying money, but these investors do literally nothing productive, it's basically just a flaw in the system that they exist at all.