Credit card processors charge large fees on transactions, which is a huge tax on just about... everything.
You can make a lot of that tax back via rewards. And not every card user has a good rewards-paying card - it's usually the more rich that do - so rewards function as a wealth transfer from the less rich to the more rich.
Very few stores have lower prices for cash, and processors try to ban that via their contracts when they can. If you pay with cash you pay the higher price to cover the credit card fees anyway, so you're just subsidizing the rewards earners. Might as well recoup some of that yourself.