It is preferred for the imam to stand in the centre of the rows and the people closest to him should be the people of intellect and understanding.
Abu Hurairah reports that the Prophet sallallahu alehi wasallam said: “Let the imam stand in the center, and close the gaps in the rows.” This is related by Abu Dawud and both he and al-Munzhiri make no further comment on its authenticity.
Ibn Mas’ud reports that the Prophet sallallahu alehi wasallam said: “Let those who are prudent and sedate be near me, then those who are next to them, then those who are next to them, and beware of the tumult of the market place.” This is related by Ahmad, Muslim, Abu Dawud, and at-Tirmizhi.
Anas said: “The Prophet loved that the emigrants (muhajarin) and helpers (ansar) stand next to him so that they would learn from him.” This is related by Ahmad and Abu Dawud. The wisdom behind having such people close to the imam is that they can correct him if he makes a mistake and it is easy for the imam to appoint one of them in his place if he needs to leave.