In the hadith of Jurjani, may Allah have mercy on him, it is also stated that when the Prophet ﷺ came out to the noble companions, may Allah be pleased with them, during his final illness, the women and children of the Ansar became so distressed that they began to weep. The Messenger of Allah ﷺ then consoled them, delivered a sermon, and then spoke the aforementioned words.
Hadith Referenceالسنن المأثورة / باب عمارة الأرضين / 435
Hadith Takhrijصحیح بخاری، فضائل الانصار، باب قول النبي ﷺ اقبلوا من محسنهم وتجاوزوا عن مسيئهم، رقم: 3799