Here's Tony Stark's (Robert Downey Jr.) real reason for creating the Iron Legion in The Avengers, Marvel Studios followed up the ensemble film and kicked-off Phase 2 with the Shane Black film. The third and final solo movie for MCU's inaugural hero, Iron Man 3 tackled Tony's PTSD following his near-death experience during the Battle of New York.
One of the few films in the MCU that solely focused on the character without the story getting bogged down with Marvel Studios' world-building efforts, Iron Man 3 pit Tony Stark against Aldrich Killian (Guy Pearce), who used the fake Mandarin (Ben Kingsley) to stoke fear. Aside from battling a traditional superhero villain, the genius, billionaire also struggled personally with PTSD. As a coping mechanism, he began obsessing over trying to protect the people dearest to him. The general assumption is that this was the reason why he created the Iron Legion, but it turns out to not be the case.
In the book The Wakanda Files, Tony's real motivation for creating dozens of remotely-controlled Iron Man armors is revealed. As the MCU's inaugural hero pondered on the events of the Battle of New York and the devastation it left on the city, he came up with the idea that could help them minimize the civilian casualty in case another metropolitan-set battle happens in the future. This led him to "activate and assign an Iron Legion to the Avengers cause;" with the use of automation, he predicted he was able to come up with a dozen suits in at least a week, and by the time of Iron Man 3, he had 35 flying suits. Tony also tasked JARVIS (Paul Bettany) in "remote-controlling a few units individually as needed," which explains why the AI was had access to several units as seen in the film.
Tony also wanted to utilize the Iron Legion as back-up if the Avengers ever faced a massive army as they did in The Avengers. While Spider-Man: Homecoming, he also partnered with the U.S. government to create the Department of Damage Control (D.O.D.C.), which took over the cleaning up of the city.
This new information from the Wakanda Files highlights how proactive Iron Man had been when dealing with potential threats on Earth. Even after the superhero team split up in Rhodey/War Machine (Don Cheadle) in Iron Man 3 that he thought they're not enough "for what's coming" — a reference to his premonition of another extraterrestrial attack which eventually happened in Avengers: Infinity War.