When you buy something using a credit card the retailer is charged a fee by the credit card company. If the goods are returned I suspect, but don't know for sure, that the fee, or part of it, is returned to the retailer. The fee for debit card use might be lower than that for credit card use so it pays the retailer to return payments via a credit card wherever possible.
Some credit cards give cashback - I get a small percentage off all my annual spending one one of my cards as a bonus at the end of the year. I could make money by buying things on credit card and returning them via debit card if you were allowed to do that.