For many jobs, the pay and working conditions really are a product of market forces. For other jobs, not so much.
For software jobs, and for jobs with garbage pay and which also suck, it's mostly true. People who can competently write software aren't that common, and there's tons of jobs and demand for them, so the pay goes up, and companies compete with each other for them by offering better pay, better perks, etc. Jobs which both suck and have horrible pay are that way because there's desperate people willing to do them, and because those jobs generally have a very low barrier to entry.
CEO jobs aren't very common, and are largely a factor of "who you know". Going to the right fraternity in college is more important than how competently you can run a company, so obviously it's not a merit-based job.
As for immigrants with medical degrees, here again there's a barrier to entry: you can't just immigrate here and get a medical license by taking a test; the industry actively limits how many licenses they allow.
>In western societies, no job should pay less than a living wage, no matter how enjoyable it is.
Software jobs that pay poorly DO pay "living wages"; they surely pay far better than any random horrible minimum-wage job. You're not going to get any sympathy from me about not getting paid "enough" for some software job that doesn't pay median pay, but is more "fun". If you want more money, go find a big-corporate job that's boring as hell but pays well. Nothing is stopping you.
For actual shitty jobs, this sounds good, but how do we enforce it, besides simply raising the minimum wage? And there is an argument to be made that raising the minimum wage will simply cause many of these jobs to go away (increasing unemployment), and also cause the prices of products and services to raise, increasing inflation so that poor peoples' purchasing power isn't any better than it was before.
IMO, what we really need is more automation, plus a Basic Income so that people forced out of work by the automation can still enjoy the fruits of society's success without having to toil in some pointless bullshit job, and perhaps use their free time and efforts to do something more productive (like start an innovative new business, write a best-selling book like Harry Potter's author, etc.). Automation is going to put more and more people out of work by rendering so many jobs obsolete, as machines can do them faster and more efficiently, and as a society we need to prepare for that. Remember, a century ago people thought that in the 2000s, we'd all be working 10 hours a week.