It’s for the giver.
You have two things happening at the same time. First, you have the people who are paying their respects. They feel a sincere desire to supplement their verbal/emotional support to the family with a tangible token of sympathy. In most Western cultures, this is traditionally flowers (can be combined with cards, food, and/or cash toward funeral expenses).
Yes, I do laugh affectionately at my elderly aunts, who are outwardly very nosy at wakes and funerals about who sent “good” flowers and who was a little cheap, but while this is eye-rolly on the surface, I truly think their interest in sending flowers comes from a lifetime of being part of a culture where this is a cherished tradition.
Second, the family of the deceased, who have realized that people are going to spend money ON SOMETHING, feel it would be more productive on a societal level for that money to go to charity, and plus it’s easier for the family than having to deal with an insane number of flower arrangements after the funeral services (although a funeral home can assist with that).
So the donation is a way for families to say “we really have no use for flowers” and for the flower-givers to feel like they have an outlet for their formal expression of sympathy.
This is describing what happens in cultures/subcultures where formal traditions and customs about death and mourning are highly valued – obviously, if people don’t care, it doesn’t matter at all.