Actually, many businesses had a credit surcharge for a while. Then the credit cards added a no surcharge clause to the merchant contracts. So they hiked their prices and offered a cash discount. Then the credit cards added a no cash discount clause.
Yes, services cost money. That's no excuse for hiding how much it costs and forcing it to be paid for by people not using the service (for example, everyone that pays cash).
Many merchants prefer cash because cash can't be charged back after the fact. For example, if the card turns out to be stolen but not yet reported or the customer files a false claim.