The key words here are "a basic" level of housing. A house in the most exclusive area of town will always be an investment (not necessarily a good one), because it primarily offers exclusion of other poorer members of the society from your surroundings, not habitation for yourself. It can't be affordable by definition.

But a basic level of housing is a human right, because it's a prerequisite for maintaining your humanity, ditto for healthcare.

It's also possible for housing to be neither affordable nor an investment. If there's an expensive area of town, and property tax is 100%, that would be expensive and I don't think people would consider it an investment.