The regrets of those who die, show the next generation what they should focus on while they are still alive. The fact that these regrets appear just before people die confirms that they made the wrong choices. Others should learn from that.
The deceased will not have any benefit from it anymore, just like drug addicts that die from an overdose, or smoking. The fact that they don't have any benefit from it anymore is irrelevant. The reason why they have regrets is important.
They realize they made a mistake, and making a mistake means that there were other and better options at that time.