It is narrated from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) that the homes of the Ansar were far from the mosque, so they intended to move close to the mosque. Then this verse was revealed: "And We record what they have sent ahead and their footprints." The narrator said: So they stayed (in their own homes).
Imam Ibn Majah (may Allah have mercy on him) narrated it like this in his Sunan.
Related hadith on this topic
Explanation & Benefits
Maulana Ataullah Sajid
Commentary:
For the people of strong resolve (ahl al-‘azimah), it is preferable to live farther from the mosque. However, for ordinary people who are not accustomed to such diligence in performing the prayer, it is better for them to reside near the mosque so that they do not fall short in fulfilling the obligatory acts.
Source: Commentary on Sunan Ibn Mājah by Mawlānā ‘Atā’ullāh Sājid, Page: 785