Lust for Power
Agahnim was once part of a group of Wind Mages under the rule of Vaati. He wasn't particularly known for anything, though once Vaati disappeared and didn't return, Agahnim became obsessed with growing in Power and taking Vaati's place. Not long afterwards, Ganondorf, the epitome of Power itself, was defeated and sealed within the Sacred Realm. Although Ganondorf was not Agahnim's master, Agahnim's obsession compelled him to worship Ganondorf. The sorcerer then went under-the-radar for about a year...
Attack on the Sacred Realm
Then, out of nowhere, he appeared in the Sacred Realm after having acquired an insane amount of Power through unknown means. Before any of the Sages could react, Agahnim used his corrupt energy to attack the Sacred Realm in an attempt to break the seal on his proclaimed master, Ganondorf. However, his newly found powers were not enough to break the barrier; all it did was crack it. He escaped before the Sages arrived. Although the barrier did not break, the crack seemed to slowly grow over time. To fix it, the Sages used their powers to transfer energy from the Sacred Realm into the barrier, fixing the seal, but unfortunately causing a hole in the Sacred Realm. Its incredible magical powers leaked out and spread to all of Hyrule, and since the gateway was open to Termina and Subrosia, the power spread to those two lands as well, granting anyone with the ability to use Magic.
Building an Army
Since then, corrupted minions have appeared through the lands of Loftis, all of them possessing similar corrupting powers to Agahnim, altering whatever they touch into a servant of evil. They've attacked randomly in almost every location, though every attack had only been one or two minions at a time, so usually these attacks never succeeded, but it did bring a message - Agahnim was building an army as his power grew in the background, and he was preparing for something big. Despite this, Hyrule couldn't defend against Agahnim's attack when he made his move...
Sealing the Fairies
No matter who Agahnim killed, they would usually be brought back to life by a Fairy. In order for Agahnim to take over Hyrule (and eventually all of Loftis), he had to find a way to stop the creation of more fairies. As he was building his army, the "random minion attacks" were actually a distraction while he placed seeds of corruption in each Fairy Fountain, first by obtaining a Fairy, and then returning it to a Fairy Fountain, with just a slight change. Lucky for him, the Great Fairy never noticed the change. Once he had an altered Fairy in every Fairy Fountain, he used his newly built army to attack.
Attack on Death Mountain
Suddenly, many of the creatures that lived on Death Mountain went on a rampage. They all targeted Goron City, and with help from Agahnim's army, they were able to break into the city's defenses. Although it looked like an all-out attack on Death Mountain, Agahnim's actual goal was to defeat and corrupt the Great Fairy atop Death Mountain's Fairy Fountain, so he used the attack as a massive distraction. It worked all according to keikaku plan, and once he activated the corruption within the altered Fairies, he was able to defeat the Great Fairy with ease. By the time anyone got up there, all Fairy Fountains in the land were corrupted with his powers, and though two of the Sages battled with him briefly, he was able to escape.
Rebuilding Once More
Unfortunately for Agahnim, he ended up losing most of the army he'd built up. Once the Kokiri, Hylians & Sheikah joined the battle, they were able to take down his army quite easily. Since then, Adventurers have tried to cleanse the Fairy Fountains, but they've only been successful on a few so far. In the meantime, Agahnim rebuilds his army once more. The next time he attacks, he'll have the Great Fairy on his side. He could very well win the next battle...