The formation of the Avengers forms the spine of Phase One of the Marvel Cinematic Universe. As they charted this path, the brains at Marvel Studios knew that they needed a good excuse for that group to form. Each of their superheroes was capable of handling most situations on their own. Getting them together in The Avengers would require a major threat.
Due to various circumstances, including character deaths and actor departures, they had to get Loki in the role. This turned out for the better, as the character, played brilliantly by Tom Hiddleston, would become one of the MCU’s break-out stars.