All perfect praise be to Allah The Lord of the Worlds and may His peace and blessings be upon our Prophet Mohammad and upon all his family and companions.
One of the Prophetic narrations mentioned in this regard is the following: Abu Mas'ud 'Uqbah bin 'Amr Al-Badri Al-Ansari (May Allah be pleased with him) reported: Messenger of Allah (PBUh) said: "The person who is best versed in the recitation of the Book of Allah, should lead the prayer; but if all those present are equally versed in it, then the one who has most knowledge of the Sunnah; if they are equal in that respect too, then the one who has emigrated (to Al-Madinah) first, if they are equal in this respect also, then the oldest of them. No man should lead another in prayer where the latter has authority, or sit in his house, without his permission". [Muslim, No. 673].
Muslim jurists have done Ijtihad (Analogical reasoning) to understand this Hadith and make it means of analogy. They have arrived at the conclusion that the criteria for determining who should lead the prayer is as follows: "The most entitled to lead the prayer is: the most knowledgeable of Islamic Jurisprudence, then the best versed in the recitation of the Book of Allah, then the most prudent, then the one who has emigrated to Madinah first, then the one who is senior most in accepting Islam, then the descendent of Quraish, then the one best in conduct, then the one who is the cleanest of body and clothing, then the one who has the best voice, and then the one who has the best looks. One who enjoys any of these virtues should be given precedence in leading the prayer. However, if many enjoy these virtues, then they should be given precedence according to the aforementioned arrangement. If two of them had equal virtues and differed on who should lead the prayer, then it should be settled by voting.
Moreover, the Imam of a mosque and the resident of the house should be given precedence over the most knowledgeable in jurisprudence and the one that comes next, and these two are at liberty to allow whoever they want to lead the prayer. In addition, the ruler is given precedence, then the highest in rank amongst the judiciary, then the governor takes precedence over the resident, the mosque`s Imam and others.
Further, the one who is present is given precedence over the one who is traveling, the free man over the salve, the upright over the wicked and the adult over the child, even if they were more versed in jurisprudence. Also, the blind should be treated as equal to the seeing." {Ummdat As-Salik, vol.145/ pp.144}.
As for giving precedence to the one who has knowledge of the rulings of prayer over the one who memorizes the most from the Noble Quran, it is because there is more need for understanding the rulings of prayer than memorizing lots of chapters.
It is also because the Prophet (PBUH) has given precedence to Abu Baker in leading the prayer although there are other companions who memorized more chapters of the Quran than him. Commenting on the above Hadith, Imam Shafie said that early scholars were knowledgeable in jurisprudence and were best versed in the recitation of the Book of Allah. In other words, they have mastered both fields. The above Hadith has also referred to descendants of Quraish, in addition to scholars and people of righteousness of the same Caliber.
As for giving precedence to the one who is the cleanest in terms of garment and body, in addition to other virtues, it is because that leads to attracting the hearts of the prayer performers and so increasing their numbers. This stems from the fact that they respect that Imam, attain humble submissiveness during prayer and get touched by the beauty of his recitation. Kindly refer to {Moghni Al-Mohtajj, vol.1/pp.486-488}. And Allah Knows Best.