Tony Stark worked obsessively to create the Iron Legion in Iron Man 3 and the book Wakanda Files reveals his real motivation behind creating them.
Here's Tony Stark's (Robert Downey Jr.) real reason for creating the Iron Legion in Iron Man 3. After the success of 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 the Chitauris were fairly easy to take down, the heroes struggled to contain them because they were ridiculously overwhelmed and outnumbered. Acknowledging this as a room for improvement, Iron Man thought that a string of specialized armors could help them in this regard. Aside from being a physical extension for the Avengers, Tony thought that the Iron Legion can help with information dissemination, using the suits "to effectively communicate with the general public so there isn't any misinformation." It's worth noting that this wasn't Tony's only post-Battle of New York project; as revealed in 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 Captain America: Civil War, he continued to work on his own, staying committed to their cause as Earth's defenders. That said, this also seems to directly contradict what's previously revealed as the primary reason behind the creation of the Iron Legion. Tony explicitly told 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.