Your ideas are mixed up here.
Companies are not 'discriminating' against people in other countries due to 'lack of legal protection'. They are just hiring people in other countries, and paying them what they are worth.
That's it.
It's 100% supply and demand.
There are good and bad developers everywhere, and cost of living and opportunities are different everywhere.
Supply and Demand will work itself out.