For cash you have to count and recount that cash at the end of the shift, and then the bank counts are recounts it again. This is a significant amount of labor. By contrast with a card once the initial transaction is done everything is put into the computer electronically and no human has to look at it again.
Also cash is subject to theft. In some locations this risk is a significant part of the transaction costs - not just the cash, risk of death in the robbery. Electronic payments are subject to loss, but generally there is a trail to chase when it happens, and the possibility of death is much less.
Until 2016, the costs were 30€/mo+0.125% for EC, 160€/mo+4% for VISA and MasterCard, 160€/mo+7.5% for AMEX in Germany.
Most German merchants run on margins below 1-2%. Good luck paying 7.5% transaction fee on a margin of 1%.
This is why EC was far more widely accepted, although even that was too expensive for small places, such as farmers selling stuff on the market.
Such studies have also been used to arrive at the EU interchange cap.
[0]: http://www.steinbeis-research.de/images/pdf-documents/CFP_Co...
But yes tax avoidance is a huge problem in restaurants in Germany.