No, obviously not always done for selfish reasons, but occasionally. As I said earlier, I had messages from people who I knew didn't particularly care, but just felt they should say something, and those 'thinking of you' messages that didn't actually mean anything real didn't help me - or people feeling like they should sign a card, comment in some way, and frankly, they don't always really care very much. They can't say that, though
I guess my point is that its impossible to know what someone’s motivation is for sending a message like that. There may be a percentage of people who don’t really care but feel it’s expected of them, yes. But I firmly believe that the vast majority of people, when anyone is facing a genuinely traumatic and tragic situation, will feel some compassion even if they don’t massively care about the person. That’s where the humanity comes in.
We don’t have the emotional capacity to feel huge empathy for everyone we know day to day and you can’t blame people for not being hugely emotionally invested in the lives of people they don’t know well. But everyone can appreciate that the death of a loved one is a horrible and life changing tragedy.
The fact that someone isn’t a close friend or even an ally doesn’t invalidate the humanity they express in the moment and I would always rather have good wishes, even temporary ones, than feel I have to interrogate the deep motivations behind them to see how “genuine” they are.
As for whether they “help”: if my spouse was dying I suspect expressions if sympathy would not make a huge difference to my state of mind. But wouldn’t you rather have compassion than nothing?