All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
It is not forbidden for a Muslim to live in a city just because there is no Masjid in it. Also, one is not Islamically obliged to move to another city just because there is a Masjid in it. Rather, it is forbidden for a Muslim to live in a place where he is not secure in regard to his religion, like if he is unable to carry out what Allaah has enjoined him to do, or he fears temptation of lusts or misconceptions even if there is a Masjid in that place.
Allaah Knows best.