When you take money to buy something, the merchant will temporarily keep it and then deposit it in the bank or buy goods. This process will cost a certain amount of money (please keep it/spend your time managing it/provide corresponding safety facilities, etc.). ), and banks will also increase their workload because of cash delivery. These are all costs.
With the credit card transaction, the whole process is automatically delivered by the electronic system, and the costs of cash transportation and storage are all saved.