We have the example of the prophet Yusuf. He opted to live in the land of of a non Muslim king rather a polytheistic kingdom, Egypt. He obeyed the public law and he worked for the benefit of the country.
Another example is that The Muslims in Makkah were not allowed to fight back against the persecution they were facing, instead they were asked to migrate from the land. It shows that if one’s own land doesn’t give freedom to practice faith and religion one needs to leave it.
The whole world is the land of Allah. Wherever one lives one should live like a good citizen and make oneself a part of the community. However one should not compromise on one’s religious duties.