I don't think the decision is as 'black and white' as you are making it out to be.
Here is an example, from a situation I saw play out over some years. A couple had a daughter together, but they were both drinking and using, and there were domestic violence incidents between them by both sides. The child was put into state care.
A year or so later, Mom finished her parenting classes, rehab, and was given custody again. However, there was still a lot of chaos because the father kept coming back in and out and there were more DV incidents and she had a DUI.
So the child was returned to state care, back to same family she had been with from age 1 to 2 and a half.
A few years later, Mom sobered up, married a stable working man and they had two little boys. CPS was watching but she was doing fine and so her sons stayed with her.
Mom now wanted her daughter to be returned to her. But her daughter was now 8 years old, been in the same family for years and was very close to her younger siblings and grandparents. She did not want to go back and live with her birth family, even though she had visits with them over the years.
I think, by your 'black and white' version , this child should be forced to be returned to her bio mom, in spite of her entire childhood being surrounded by another family environment.
I think the child's desires should be taken into account, JMO