So if you're a unique, highly sought-after expert, the country doesn't make much of a difference directly, because people like you a generally hard to find.
But for a pre-senior level, there's a lot of people available, so the amount the client is willing to pay is determined by how much other people like you (from a place like yours) are willing to work for, which obviously depends on the country.
And then there's the selection bias. If the reason you got found is because the client has been looking for developers in your country, chances are that the client is looking to save money and isn't willing to pay much. Those clients who are willing to pay more generally look in different places.
And finally, a US-based client working with a US-based contractor is protected by US laws, unlike when working with a contractor from a developing country with a less reliable judicial system.
I heard a lot of stories about companies paying different just basing on where the programmer lives. Eg. if he switches location, he automatically gets less/more money. This is a biggest nonsense for me I want to clarify.
I think that matters because it lowers the wage you can put up with. Thinking from an employer perspective, assuming non-specialist skills, it's more costly to work with someone remote in a different timezone (b/c communication difficulties, etc), so they'd only do that if they can push your wage low enough so they come out ahead with the extra costs vs. a local developer. They also like money, so if they can push your wage down further than that, they'll try.
I really don't get why the place I'm working from determines how much do I earn.
Am I bringing less value working from Malaysia than from London? I think the value you bring in should be the only factor what your salary depends on.
Can somebody shed some light on it? I know there are some arguments like costs of living, but why it should be even considered? It's totally up to you where do you live.