If a non-Jew sincerely wishes to be a resident alien [ger toshav], to abandon idolatry and undertake the seven Noahide laws, thereby sanctifying G-d’s name, better that he should do this and live in Eretz Yisrael than to live outside the Land as an idolater and profane G-d’s name. Clearly, however, all this applies only if he accepts conditions guaranteeing that he remain isolated from Israel, and ensuring his understanding that Eretz Yisrael is the exclusive land of the Jewish People and that he has only the right to reside there.
Therefore, besides the conditions enumerated above, the Torah established additional restrictions. First, Sifri says [Ibid.), “‘In your midst’: And not on the border.” The reason for this is simple. We still suspect him lest he aid the enemy and endanger us. Second, Sifri teaches (Ibid.), “‘[To reside]… in your gates’ (Deut. 23:17): In your gates and not in Jerusalem.” Jerusalem’s holiness cannot bear the impurity of a non-Jew, hence, even a non-Jew allowed to live everywhere else in Eretz Yisrael is forbidden to live in the Holy City. It would seem that to live there while passing through is permitted, for that is not called “residence.”
Sifri also teaches (Ibid.): “‘He shall be allowed to reside with you’ (Deut. 23:17): And not in the city itself.” I believe the simple interpretation of this is that although a particular non-Jew can be permitted to live in Eretz Yisrael “with you,” …we are still required to separate from him, hence we are forbidden to settle him among us in the same city with Jews.
…we are allowed – not obligated – to let such a non-Jew live in Eretz Yisrael. If, for any reason, we fear danger or deception, then we are certainly permitted and required to forbid every non-Jew, even the resident alien, to live in the Land(after all, even converts were rejected during certain periods for certain reasons).