Playing the devil's advocate here:
Under capitalism, you could also see it as a provision of services where the landlord invests in the means of production (the building) and provides the service of letting people stay there for a certain amount of money. The offered services include the maintenance of the building. If a landlord is keeping a building poorly maintained and/or expects an over the top rent, then this is simply a bad service.
But well, this obviously doesn't work out as soon as you consider a safe place to live a basic human right that mustn't be commodified.