If David Milliband had won, the tories would have gone into an election talking about his complicity in the kidnap and torture of a pregnant woman as part of the extraordinary rendition program with the CIA. Fatima Boudchar's name and face would have been on the front of every newspaper in the country, and dave would have been painted as an utter monster for it. And the tories would have won bigger than against Ed.
Corbyn in 2017 recorded the biggest swing in votes since the war, and through all of May's post election time was ahead in the polls. It would have been madness to replace him at the time. It took the media (BBC put his face on lord voldemort for crying out loud) and his own party (4 labour MPs have been enobled by the tories for their work in losing 2019) to get the end result of johnson.