The Messenger of Allah ﷺ used to walk through the rows from one side to the other, touching our shoulders and chests, saying, "Do not be uneven, for then your hearts will fall into discord." He would also say, "Indeed, Allah and His angels send blessings upon the front rows."
أخبرنا قتيبة بن سعيد قال حدثنا أبو الأحوص عن منصور عن طلحة بن مصرف عن عبد الرحمن بن عوسجة
كان رسول الله ﷺ يتخلل الصفوف من ناحية إلى ناحية يمسح مناكبنا وصدورنا ويقول لا تختلفوا فتختلف قلوبكم وكان يقول إن الله وملائكته يصلون على الصفوف المتقدمة
[Its isnad is sahih] Abu Dawud transmitted it in the Book of Prayer, chapter on straightening the rows, hadith 664, from the hadith of Abu Ahwas through this route, and it is in al-Kubra, hadith 885. Ibn Khuzayma graded it sahih, hadith 1556 and 1551, as did Ibn Hibban, hadith 386 and elsewhere.