There are certain transactions that don’t begin and end with the payment of the cost of the service. When renting an apartment, you are able to cause far more damage to the apartment than the rent you pay, hence the apartment owner has an incentive to also consider what kind of person they are renting an apartment to.
A credit check serves as a proxy for someone who cares about their future reputation and hence is less likely to cause damage to an apartment, and if they do, then they will pay for it. Similar reasoning applies to other rental businesses such as hotels, cars, tools, equipment, etc.