I have a family member who works for Wells Fargo and discovered this while talking to him and a programmer friend of his. They work on the systems that move money around between accounts, and I work on a shitty half-thought-out web app. I'm paid like 2x what they are.
There are plenty of things that are important that the “market” doesn’t allocate a ton of money towards and tons of stuff that are really not important but the “market” rewards. The market in the end is a collection of decisions by individuals in aggregation, and decisions by humans are rooted more in their psychology than in some uber rational god mind of optimality. It is very possible to shape behavior, decision making, and capital allocation in ways that are demonstrably pessimal. Indeed with the advent of mass consumption of social media and algorithmic manipulation of psychology you can shape market behavior directly in ways that are detrimental to the participants in the market while rewarding the manipulators. This can be even done as a method of warfare, in which you shape psychology, behavior, and market preferences against a societies best interests.
This is why we have non market systems that prioritize objectively important work that’s inefficient by the market’s perspective. This is essentially the outcome of 248 years of economic research after the wealth of nations.
No, "the market" isn't all knowing and infallible. It's wrong very often. And the way it allocates capital is often not optimal in any way.
People like you argue that scamming old people is an important activity because it allows capital to be better employed. I mean, "the market" wouldn't reward the scammer with a living otherwise!