The environmental factors are huge - my wife used to get students who rarely slept two consecutive nights in the same place - but another challenge seems to be threshold effects. Below a certain level the teacher has little control (e.g. a hungry kid needs lunch more than the best teacher) and over a certain level the kid has so many positive influences (high functioning affluent parents, tutors, competitive peers, etc.) that they’re going to do well with all but the worst teachers. The area where a teacher has the most control seems to be in between, with the kids who could coast but will do more if pressed and may not have other encouragements.
Most of the political discourse tends to treat all of those situations as the same.