All perfect praise be to Allah, The Lord of the Worlds. May His peace and blessings be upon our Prophet Muhammad and upon all of his family and companions.
If the child is seven and performs prayer properly, then he is allowed to stand in the first row either to the right or left of the Imam, and if he stood there, then it isn`t allowed to move him away because whoever comes first to a place of prayer deserves it more than the one who comes after. The evidence on this is that Abu Huyrayra (May Allah be pleased with him) narrated that the Prophet (PBUH) said (What means) :" If a man gets up from his spot then comes back to it, he has more right to It." [Muslim].
Moreover, it is preferable for such child not to stand directly behind the Imam Imam since the Prophet (PBUH) said (what means): "Let those be nearest to me in Salat (prayer) who are mature and possess (religious) knowledge, then those who are nearest to them in these respects". He repeated this three times." [Muslim]. Furthermore, it is recommended that the more prudent and sedate in Sharia should stand directly behind the Imam so that they could correct any possible mistake during prayer or, even, lead the prayer on his behalf according to the aforementioned Hadith since a child can't do so. Therefore, moving a child away if he stood directly behind the Imam is permissible.
However, if the child is under seven, then he can`t stand in the first row and should be moved to the back since, in principle, fathers shouldn`t bring their under-seven-years old children to the mosque. This is because they could disturb the prayer performers, play with the Qurans and other properties, and render the mosque untidy. However, if a father had to bring his child to the mosque , then he should keep an eye on him and avoid praying in the first rows.
In conclusion, the Imam shouldn`t move all the children from the first row. Rather, if the child is seven and older then he can`t make him go to the back rows, but if he is under seven then the Imam has the right to make him go to the back rows. We advise the asker that if his child`s praying in the first row could cause trouble in the mosque, then he should make him pray behind him directly. And we ask Allah to reward you. And Allah the Almighty knows best.
*Note: This Fatwa was modified on April 3, 2022, where it was differentiated between a child who is seven and a child who is under seven.