When accepting payment by debit card, merchants pay a fixed transaction fee (as opposed to a percentage) to their bank or merchant services provider. (This is because the commission paid by the merchant for accepting debit cards, unlike credit cards, does not need to fund interest free periods or other incentives).
Accepting payments in cash can be costly for merchants, given that many British banks charge around 0.5% for depositing cash into a business bank account, along with the costs of transporting and insuring the cash.
The combination of these two points means that the retailer can save money by offering the cashback service. It does not cost the retailer more in service charges to add cashback to a debit card purchase, but in the process of giving cashback, the retailer can "offload" cash which they would otherwise have to pay to deposit at the bank. Currectly a maximum cashback element of £50 per transation is allowed by the cardschemes.