The thing about markets is that they cut through all of the fuzzy thinking about what jobs "should" pay more than others, and tell us what we actually pay - what we collectively find valuable. That reality escapes most people.
Imagine you live in a society where the population is mainly composed of two segments. Members of the first segment enjoy consuming service A. Members of the second segment would benefit tremendously from service B, but all the money is held by the first segment. Which service are you going to spend your time offering to the public?
This is at least part of the reason that, as a software engineer, I am much better off selling my time to an advertising company than (say) running a programming/compsci dojo for middle school kids in a low-income urban community.
You'll say, of course, that advertising is so lucrative because businesses around the world (and therefore the society made up of them) value the extra income that advertising provides. You'll say that society as a whole does, in fact, want more, better advertisements. But I suspect that there is a segment of the population just as large that would rather everyone in the advertising industry do something else. Only that segment can't pay.