Because the power is on the side of the guy giving the job, not on the guy having to pay mortgage and feed a family with two kids.
Sought after, rock-start, "I'll shop around", programmers are by definition few and far between. And even if somehow everybody managed to be one, their value and "shop-around"-ability would fall too (because there would be many to pick from).
The law must also protect regular joe employees.
Yes, but generalization is good. It's seeing what happens in MOST cases.
For one, if you can't sustain a competent business WITHOUT exploiting unpaid overtime, then you don't get to have one. Many failing businesses would be highly profitable if we allowed slave labor but we don't allow that either.
If it provides a competitive advantage to exploit unpaid overtime, regulate it to death so it's not an option anymore. And if it happens elsewhere, import-tax-it or embargo it to death, as you would child and slave labour.
Second, most companies have tens to thousands of employees. So the "guy giving the job" is not a guy, but a private or public owned entity. Far ahead of the negotiating power of the employee. And the guy deciding the "unpaid overtime", is more often than not the one with golden parachute and salary in the upper six or seven figures. So spare the melodrama for them.
You won't find many modern countries were concern over the guy "giving the job" trumps concern over the millions who have to accept a job.