While customers paying interest is a big source of income for the card company, it's not the only one.
The second is the retailer. When you pay on a credit card, the card company gets a small percentage of what you spend from the shop/restaurant and this will often cover the cashback.
Therefore, in a way, all you're doing is getting back the extra that's been factored in to pricing for all customers to cover credit card costs.
It's worth noting that Amex tends to charge retailers more than they pay when you use a Mastercard or Visa, which is one of the reasons some smaller companies don't accept it.