Just because the results of it are non-observable (fair assumption) to the person leaving some sort of legacy behind them, doesn’t mean that doing so isn’t valuable to them. It is the satisfaction you get while still living, knowing that after you are gone, some (hopefully positive) remnants of you will still live on.