Its marketing. It allows them to generate "goodwill," which is an intangible asset that companies actually list on their balance sheets.
They get to crow about "donating to charity" while spending $0 dollars, and the only operational cost is an annoying menu prompt and a separate account at the bank for the donations.