Just leave things better than when you found them. Not for you, and not for those who follow, but for the thing itself. I suppose in this framing people are things too - help them to be better versions of themselves if you can. Other than that, have fun and enjoy the ride.
To be sure we should try to take care of the loose ends if we can before we die — not knowing when that is means we should probably keep a tight ship as regularly as we can - especially more so as we get older. This thought crosses my mind fairly regularly when I look across the garage, in the storage room at all the crap I've accumulated. (Nevertheless, if the kids just want to toss everything, have an estate sale that's cool.)
But.
I am reminded that, over sufficiently long time scales, no one is remembered. There is no such thing as "legacy", really. As somebody pointed out once: how many people are remembered now from even, say, the last 2500 years? Alexander the Great, and, uh... maybe a handful more. But will even Alexander the Great, or Napoleon, or Genghis Khan, or Albert Einstein, or Ramanujan, or Marie Curie, or $INSERT_CELEBRITY_HERE be remembered in another 2000 years? 10,000? 100,000? 2 million? 10 million? It seems likely (assuming the human race even persists that long) that we're all forgotten in the end.
So I dunno. I still go back and forth in my own mind about whether or not "legacy" is even worth caring about or not.
Personally, if I leave nothing in my wake (as far as practicality allows) when I die I will be very happy. Leaving behind a legacy only inconveniences whoever it is who has to pick up the reins and clean up after me.