All perfect praise be to Allah, The Lord of the Worlds, and may His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
In order to avoid dispute among Muslims, praying behind a certain Imam isn`t an obligation. From the perspective of Sharia, it is disliked for a negligent Muslim to be an Imam.
However, there is no harm for a pious Muslim to perform that role.
Al-Imam Al-Shrbini (May Allah have mercy on his soul) said (What means): "It is disliked for an Imam whose acts are denied by most people on religious ground , as is the case in the following: Unjust ruler, took that position by power although he doesn't deserve it, doesn’t avoid impurity, changes the prayer's conditions, has unlawful work or keeps bad company, and the like-even if he was appointed by the ruler-since Ibn Majah reported: "It was narrated from Ibn ‘Abbas that the Messenger of Allah (PBUH) said: “There are three whose prayer do not rise more than a hand span above their heads: A man who leads people (in prayer) when they do not like him; a woman who has spent the night with her husband angry with her; and two brothers who have severed contact with one another.” [Mughni Al-Muhtaj vol.1/pp.489].
Al-Imam Al-Khatabi (May Allah have mercy on his soul) said (What means): "It is reprehensible for a Muslim to be an Imam by power since people will deny that. However, if he was fit to be as such then the people who deny that are sinful." [Ma'lim Al-Sunn vol.1/pp.170]. And Allah Knows Best.