Eye of the Moon Plan

The was created by Madara Uchiha as a way to bring peace to the world. Though its execution does not go according to plan and some further it for their different personal motivations, the end goal remains the same for all involved: projecting the Infinite Tsukuyomi on the moon in order to trap the entire world in a dream, thus saving mankind from destroying itself but also at the price of robbing free will from the entire world.

The Plan in Theory
From a young age, Madara Uchiha wanted a peaceful world where nobody — particularly his loved ones — would need to die. In his adulthood he founded Konohagakure alongside Hashirama Senju in order to create this desired peace. Konoha quickly developed a predominately Senju-government, which Madara felt would inevitably lead to the mistreatment of his Uchiha clan; for this reason he decided Konoha failed in its goal of peace. He began studying the Uchiha's Stone Tablet and, from what he could decipher, he learned of the God Tree, the Infinite Tsukuyomi, and how a godly power could be acquired through union of the Senju and Uchiha.

Madara told Hashirama about his new dream, and then left the village. Subsequently, the two fought at what would become the Valley of the End. Madara was believed to have died, but he instead went into hiding, taking with him a piece of Hashirama's flesh. He integrated it into his own body and, decades later, awakened the Rinnegan. With the Rinnegan he summoned the Demonic Statue of the Outer Path from its storage on the moon, and from it he cultivated White Zetsu's. Now that he had the means of peace at his disposal, Madara began formulating his Eye of the Moon Plan in earnest: he would collect the nine tailed beasts into the Demonic Statue in order to reform the Ten-Tails, which he would then become the jinchūriki of in order to cast the Infinite Tsukuyomi, thus ending all conflicts while also erasing or rather destroying free will in the process.

Madara realised he could not complete his plan during what remained of his natural lifespan. He implanted his Rinnegan into a young Nagato so that their power would not be lost upon his death and so that Nagato could someday restore Madara to life. In order to manipulate Nagato to that outcome, Madara would need an agent to act for him on his behalf; he connected himself to the Demonic Statue to keep himself alive until such a person could be found. During the Third Shinobi World War, Madara discovered a badly-injured Obito Uchiha, who he believed would suit his needs. While treating Obito's injuries Madara secretly branded Obito with a Forbidden Individual Curse Tag so that Obito would never act against his wishes. Once Obito recovered, Madara manipulated events so that he witnessed the girl he loved being killed by his best friend and childhood rival, thus breaking Obito's ties to others and giving him a reason to want the Infinite Tsukuyomi carried out: to create a world where tragedies like the one that befell him would not happen.

With Obito having been corrupted to his liking, Madara shared with him all he knew: of history, the secrets behind certain techniques and abilities, and whatever other steps Madara had already taken. He left Black Zetsu for Obito, believing it to be a manifestation of his will that could guide Obito after he was gone and, if necessary, force the completion of Madara's plans. Madara then disconnected from the Demonic Statue and, before dying, entrusted Obito with his possessions, his plans, and his name until such time that Madara would be brought back to life. But Obito did not trust Madara and as such had no intention of ever bringing him back. He would follow Madara's plans, but it would be himself, not Madara, who became the Ten-Tails' jinchūriki and performed the Infinite Tsukuyomi; Nagato's purpose would be to revive him in case anything happened to him before then.

Unbeknownst to Obito or even Madara, Black Zetsu had its own motives. Rather than being a manifestation of Madara's will, it was actually a manifestation of Princess Kaguya Ōtsutsuki's will, having been created before hers and the Ten-Tails' defeat by the Sage of the Six Paths centuries ago. Since then it had been trying to create a Rinnegan so that the Infinite Tsukuyomi could be used and Kaguya could be brought back to life. When it discovered Madara it found the perfect pawn, and as such secretly altered the Stone Tablet so that Madara would start taking the desired path. Black Zetsu allowed Madara to believe he had created it so that it could take a direct role in guaranteeing the Infinite Tsukuyomi was performed correctly, intent on hijacking the caster immediately afterwards in order to bring Kaguya back into the modern ninja world.

The Plan in Practice
After Madara's death, Zetsu and Obito — using Madara's name — approached Nagato's organisation, Akatsuki, with an offer of support. The leader at the time, Yahiko, refused his help, but Obito claims he later changed his mind. Upon Yahiko's death due to Hanzō, Nagato summoned the Demonic Statue and linked himself to it in a failed attempt to avenge Yahiko. In the aftermath, Nagato became the new leader of Akatsuki and he accepted Obito's assistance and guidance, though only he and Konan would ever know of Obito's contributions.

Obito told Nagato, a victim of the world's wars, that the world could be forced to stop fighting by creating a powerful weapon from the nine tailed beasts. Over the following decade, Nagato led Akatsuki to that end, first gathering manpower and resources before it began capturing the tailed beasts. In time, Akatsuki succeeds in sealing the first seven beasts into the Demonic Statue; by then both Zetsu and Obito (using the alias of "Tobi") join Akatsuki as members. But such successes came with several costs: through frequent conflict with Konoha-ninja, Akatsuki loses most of its members; Nagato has a change of heart and gives his life to revive the villagers of Konoha he killed during Pain's Assault, with Konan defecting from Akatsuki afterwards; because the tailed beasts were predominately possessed by the Five Great Shinobi Countries, capturing so many compelled a response to Akatsuki by the ninja world.

With Akatsuki no longer able to move in the shadows and with the Eye of the Moon Plan's completion so near, Obito starts taking drastic measures. He sends Sasuke Uchiha to assault a Five Kage Summit held in the Land of Iron, hoping to weaken the convened Kage enough to force them to cooperate. When Sasuke fails and is nearly killed, Obito, still using Madara's name, steps in. After getting Sasuke to safety, he shares details about the Eye of the Moon Plan and the peaceful world he hopes to create with those assembled, and asks that they hand over the two remaining tailed beasts, the Eight-Tails and Nine-Tails, in order to help him achieve this peace. He is refused, prompting him to declare the start of the Fourth Shinobi World War.

While the ninja world organises itself into the Allied Shinobi Forces and Obito readies the White Zetsu Army, Black Zetsu becomes concerned that Madara's plans are not being followed. As such, it approaches Kabuto Yakushi and reveals Madara's resting place to him so that he can use it to reincarnate Madara and blackmail Obito. Obito reluctantly accepts Kabuto's assistance with the war effort and goes to Amegakure to retrieve Madara's Rinnegan from Nagato's body. He implants the left Rinnegan into himself and hides the other, partly because he is unable to handle the power of two Rinnegan but predominately because he does not want Madara to have it.

The first day of the Fourth Shinobi World War is largely uneventful, though there are heavy casualties on both sides. Obito is able to acquire the Kohaku no Jōhei and Benihisago, within which are sealed the Gold and Silver Brothers, who have some of the Nine-Tails' chakra. On the second day, the Nine-Tails' jinchūriki, Naruto Uzumaki, enters the fight and almost all of Kabuto's reincarnated forces are defeated, forcing him to mobilise Madara. From the fact that he has not been revived correctly, Madara can tell Obito has deviated from the plan. When Obito learns of Madara's appearance on the battlefield he tries to capture Naruto and Killer B, the Eight-Tails' jinchūriki.

Obito is unable to capture either Naruto or B by the time that Kabuto is defeated. With his time running out, he places the Kohaku no Jōhei and Benihisago within the Demonic Statue to, in combination with the other seven tailed beasts and a portion of Eight-Tails's chakra that Akatsuki acquired in a prior failed attempt to capture it, begin the Ten-Tails' rebirth. Madara, having cancelled his contract with the Impure World Reincarnation, tracks Obito down and chides him for failing to follow the Eye of the Moon Plan as he envisioned it. Madara tries to capture B and Naruto before the Ten-Tails is reborn, but he is unsuccessful. Obito and Madara take control of the Ten-Tails to try and destroy the remnants of the Allied Shinobi Forces, but enough survive to separate the Ten-Tails from their control.

In the confusion that follows, Obito is able to leave the battlefield long enough to remove the Forbidden Individual Curse Tag from his body, releasing him from Madara's long-standing influence. When he returns, Madara attempts to force him to use his Rinnegan to restore Madara to life, but this fails when Obito defies Madara's control and instead seals the Ten-Tails into his body. Once he gains control of the beast's power, Obito, because he lacks dual Rinnegan, creates a tree-form of the Ten-Tails, the flower of which will be used to cast the Infinite Tsukuyomi. Madara can't do anything to stop him due to the limitations of his reincarnated body, so he informs the Allied Shinobi Forces of what Obito is planning, indirectly spurring their counter-attack that removes the tailed beasts from Obito's body.

From his defeat and a conversation with both Naruto and Kakashi, Obito decides that all he's been doing up until now has been misguided and that he was only running away from his original dream of saving the world as a Hokage would. Remorseful, he prepares to restore to life everyone that died during the War. Black Zetsu intervenes at the last minute, forcing him to revive Madara instead, a move that leaves Obito greatly weakened and also near death's door. Madara, now properly alive again, is given the Rinnegan that Obito hid by a White Zetsu, which he uses to seal all nine tailed beasts — including those sealed within B and Naruto — into the Demonic Statue. The Ten-Tails is reborn once more and Madara becomes its jinchūriki. Obito escapes to the other dimension so that Madara can't have the remaining Rinnegan. Despite the efforts of Sasuke Uchiha and Naruto — both empowered by the Sage of the Six Paths — Madara is able to follow Obito and take his Rinnegan back, awakening a Rinne Sharingan which he uses to cast the Infinite Tsukuyomi.

The Infinite Tsukuyomi traps the entire world in a dream; Sasuke shields Naruto and the other original members of Team 7 from it and Obito, his body now controlled by Black Zetsu, is also unaffected. The reincarnated Hokage, being already dead, are also unaffected, but helpless to do anything. Madara then uses God: Nativity of a World of Trees to tether the world's entire population into the holy tree, drawing on their own chakra to fuel their imprisonment. His dream now a reality, Madara revels in his success, believing he has finally saved the people of the world from the horrors they enact on themselves. Naruto is greatly outraged, calling it nothing more than a lie. While Madara is preoccupied boasting to Team 7, Black Zetsu transfers from Obito's body to his, which it achieves by stabbing Madara in the chest by using Obito's left hand. Zetsu tells a shocked Madara that Madara is not the saviour nor is Black Zetsu itself even Madara's will, stating that it is the will of Kaguya, which leaves Madara horrified and stunned at the fact that Black Zetsu has been manipulating and lying to Madara all along. It takes control of Madara and uses him to start absorbing the networked chakra, causing Madara great pain and ultimately converting Madara into the body of alien Princess Kaguya Ōtsutsuki, the human incarnation of the Ten-Tails and true source of chakra. Team 7 is left shocked as Black Zetsu's work finally comes to pass.

Aftermath
Having finally been brought back to the modern world, Kaguya plans to convert the entire population that has been bound by the Infinite Tsukuyomi into her own personal army of White Zetsu. But before she can do that, she attempts to eliminate Team 7 and Obito once and for all in order to remove the last opposition as well as to reclaim their chakra, which she believes rightfully belongs to her and no-one else. After a prolonged fight, during which Obito is killed while defending Kakashi, Naruto and Sasuke successfully seal her, remove the tailed beasts from her body, and in the process confine her to another dimension. In order to prevent Black Zetsu from reviving her again — which would ultimately trigger a new World War and cost many people their lives — Naruto makes a point to personally entomb it alongside her, and as such, both Kaguya and Black Zetsu are permanently defeated.

With Kaguya finally defeated and imprisoned in the satellite, Naruto and Sasuke need only to join hands to release the Infinite Tsukuyomi. Sasuke briefly resists this, believing the world's current immobility is an opportunity to eliminate all those individuals who threaten future peace. Naruto ultimately persuades him against this although the intense fight that follows subsequently destroys the statues at the Valley of the End and costs both of them their respective dominant arms — Naruto his right and Sasuke his left — the two eventually end the Infinite Tsukuyomi together with Sasuke also finally freed from his Curse of Hatred as he acknowledges that Naruto is the victor of their battle.

Trivia

 * Because of Naruto Uzumaki's frequent interference in the activities of Akatsuki, Obito blamed him for the plan's slow progress and the deviations he had to make.
 * Madara noted that, had Sasuke Uchiha been born sooner, he would have used Sasuke instead of Obito.
 * Obito took a great interest in Sasuke's development and gaining his loyalty, even musing that he might synchronise Sasuke with the Demonic Statue. His reasons for this were never made clear.
 * Although the dream world of Infinite Tsukuyomi was planned to be full of peace and without chakra, anime adaptations of dream world include battles, deaths and wars. Despite this, the dreamer at the end would still become a "winner" in the dream.