There is plenty of profit to be made in cheap housing, just like there is plenty of profit to be made in cheap food. You can go to the grocery store right now and buy a tomato for not very much money, and the store that sold it, and trucker who transported it, and the farmer that grew it will all make money - despite food's famously slim margins.
The situation with housing is more like this: the government has dictated that only 5 acres of land in the country can be used to grow tomatos. And each tomato plant can only grow a maximum of 10 tomatos. If you are a tomato farmer, what do you do? Well, since you can't grow as many tomatos as you want, you start looking for ways to increase your margin on each tomato you sell - selling the most appealing, perfect, organic tomatos you can.
So it is with housing. When the government finally approves the development of some denser housing in a desireable part of town, the developer wants to build the highest margin housing that they can, since they won't be able to build 50 more apartment buildings. So they build luxury apartments. However, if the government said "you can build as much and as densly as you like on any plot of land here", then developers would probably start with more luxury housing, but would likely run out of luxury renters quite quickly. But then they would simply seek out more profit with the slimmer margins available in affordable housing development.