That is a supplication from the Messenger ﷺ: “Whoever is put in charge of any affair of the Muslims, whether small or great, and then makes things hard for them, O Allah, make things hard for him.” So what do you imagine will become of a person upon whom Allah makes life hard—God’s refuge is sought! It is a bargain that ends only in loss and degradation. The Prophet ﷺ also informed his community: “No governor who takes charge of the Muslims and then fails to strive for their welfare and give them sincere counsel will enter Paradise along with them.”
Whoever appoints a Muslim over a group while someone better qualified is available has betrayed Allah, His Messenger, and the believers, for offices must be given to those who are entitled to them without regard for personal favoritism. The public interest must be considered, and authority handed to the one most suited to it.
Authorities differ. The one most entitled to lead the people in the mosque, for example, is the one most proficient in reciting the Book of Allah, while the one most entitled to lead in jihad is the person most knowledgeable about it, and so on. The essential point is that the ruler of the Muslims must appoint the best among them; it is impermissible to place someone in authority when there is another who is better suited, for that is outright treachery.
Likewise, the Prophet ﷺ said: “No servant to whom Allah entrusts a flock and who dies on the day he dies while he is deceiving his flock will be allowed by Allah to enter Paradise.” God protect us.