Some countries have restrictions to give out jobs to non-residents. Hence even though you are not required to come to office, you should necessarily be a resident of that country to legally qualify for the job.