Where does the landlord get the money? Do landlords often rent property at a loss? Is being a landlord a charity, where someone takes their own money and uses it to subsidize a stranger’s housing costs?
Of course not. Landlords set the rent such that rent - costs > 0. The money to repair a rental home ultimately comes from the renter. The landlord may pay up-front, as in your example with a derelict property, but that’s with the intention of making back what they pay and more in the form of rent. Like all businesses, the cost of doing business plus all the profit the market will bear gets passed on to the consumer.