Yep. I've thought a little about this. Some ideas below, not sure if applicable.

I think part of the problem with that kind of work is that you get to see and understand on a really convincing level just how manufactured so much of everything is (to put it nicely, another term came to mind, but we'll keep it polite).

So, I hypothesize that the irreality of what is being contributed to may be just as big a part of the problem as the actual mechanics that are therefore such a slog. (And if one doesn't notice this deeper, more systemic problem, it's maybe not so much a part of the problem/solution set.)

We are told to see the bigger picture of what we are working on, and if we do that, and have a broad basis of deep-ish knowledge, then it can be sort of difficult and demotivating.

If that's case (and that's a big if), I would think about trying to put the current set of skills to use doing something similar but more "net positive".

This might be difficult to "find", and I think a person in such a place might find it most straightforward to "create" such opportunities, either finding small groups to work with or, more likely, through some kind of solopreneurship. Not sure if this is feasible for the person, but it could be a concrete action step.

Most likely some of the particulars and drudgery can be avoided, like the legacy codebases and plumbing the next questionable-utility dataset.

But some skills can be reused. Think about "data" in the most general sense possible. What are the biggest, most painful "data" problems (known or not) to individuals and societies? Knowledge of automating data intake, making this data more accessible and understandable, etc., is still needed badly, just not so much in the ways it is being done today.

I would advise doing the "good for the world" data work on the off-work hours, until it becomes profitable, which might take a while.

I think the foundational science, statistics, computers, and data moving/manipulation skills can be applied in more beneficial ways than what we are doing today. Be a part of that movement.

Think about what "causes" the person cares about that are misunderstood by most people, with the biggest negative affect caused by the broad misunderstanding. If there are no such causes, then explore all the fields of the Dewey Decimal system or random Wikipedia pages or Ted Talks or something, and find something interesting and important. Then try to find what the "real truth" of that issue and its field are. It is quite possibly the opposite of, or at least not the mainstream version of, what one would think! Or, the prominent researchers disagree (why?). Dig around and find something worth explaining better, that can be done with the skills.

Most people who care about something might lack the time and the skills to pursue this, but might have the care. The person discussed in the OP might have the skills and be able to carve out the time, and can connect with something that matters (to somebody). If the caring person or group can pay for the skills, then problem solved (maybe).

I doubt this helps much, but maybe some ideas. Good luck.

Or try to get into sales and marketing somehow, and leverage it there, maybe.