IANAL: It probably has to do with contract law more than anything else. Basically it would prevent people from being charged more than an advertised price, it would prevent confusion and charge backs. Offering a cash discount make sense as well.
In the past I have tried to ask for a cash discount on a large purchases and then vendor refuses so I pay with the card and let them take 3-5% less money anyways. It seems that even vendors do not understand how credit cards work as well sometimes.
If a 5% surchage is added to a credit card purchse:
Customer sees sign for $100 DVD player
Customer pays with a credit card and pays no attention to price charged
Customer gets statement and sees that his $100 DVD player was actually $105
Customer submitts ad to credit card company and initias a charge back
If a 5% cash discount is offered:
Customer sees sign for $100 DVD player
Customer pays with a credit card and pays no attention to price charged
Customer gets statement and sees the charge $100 DVD player
Customer is happy, credit card company is happy and the merchant is happy and there is no recourse for an incorrect credit card charge.