For a long time it was against the rules of the CC giants to charge extra for use of a CC (note: not the same as "illegal" which I have heard some say. It wasn't law, just the terms & conditions of the CC companies). Their workaround to try to keep it legal was that they did allow businesses to offer cash discounts. Subtle difference, but it tilted the field towards CCs a bit, I guess...
Some years back the CC's lost a big federal lawsuit (anti-trust?) over this and had to stop prohibiting it. But I suspect the habit got ingrained so much that many did not change. I have started seeing it more at smaller local shops & restaurants more recently, especially after the pandemic and inflation being so high these past 3 years.
Of course the problem is if I pay with cash all too often it requires breaking a hundo, and they sometimes struggle to do that. Soooo...if you want people to pay in cash, you better have enough change on hand for 50's and 100's these days as that is what comes out of the ATMs all too often...