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.

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 Naka Shrine and, from what he could decipher, he learned of the Shinju, the Infinite Tsukuyomi, and how a godly power could be acquired through union of the Senju and Uchiha.

Madara tried to convince Hashirama to assist him in following the Naka Shrine's words. When Hashirama refused, 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 Zetsus. 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.

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; 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 he branded him 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, thus breaking Obito's ties to others and giving him a reason to want the Infinite Tsukuyomi carried out: to bring Rin back.

With Obito 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 Madara or Obito, Black Zetsu had its own motives. Rather than being a manifestation of Madara's will, it was a manifestation of Kaguya Ōtsutsuki's, 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 restored. When it discovered Madara it found the perfect pawn, and as such altered the Naka Shrine 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 revive Kaguya.

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 Akastuki as members. But such successes come 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 Akastuki afterwards; because the tailed beasts were predominately possessed by the Five Great Shinobi Countries, capturing so many has compelled a response to Akastuki 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, but Kabuto's control over him prevents him from taking any direct action. 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, now freed from Kabuto, 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 influence. When he returns, Madara attempts to force him to use his Rinnegan to restore Madara to life, but this fails and Obito 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, Obito decides that all he's been doing up until now has been misguided and that Rin Nohara, the girl for whom he's been trying to perform the Infinite Tsukuyomi in the first place, would never have approved of his actions. 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. 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. Madara then uses God: Nativity of a World of Trees to wrap the world's population into the holy tree, drawing on their own chakra to fuel their imprisonment. Madara revels in his success, believing he has finally saved the people of the world from the horrors they enact on themselves. While Madara is preoccupied boasting to Team 7, Black Zetsu transfers from Obito's body to his. It takes control of him and uses him to start absorbing the networked chakra and converting him into Kaguya Ōtsutsuki.

Aftermath
Kaguya plans to convert the populations bound by the Infinite Tsukuyomi into her own personal army of White Zetsus. Before she can do that she attempts to eliminate Team 7 and Obito in order to remove the last opposition as well as to reclaim their chakra, which she believes belongs to her. After a prolonged fight, during which Obito is killed, 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 conspiring towards her revival again, Naruto makes a point to entomb it alongside her.

With Kaguya defeated, 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 and the two end the Infinite Tsukuyomi together.

Trivia

 * Because of Naruto Uzumaki's frequent interference in the activities of Akstsuki, Obito blames him for the plan's slow progress and the deviations he has to make.
 * Madara notes that, had Sasuke Uchiha been born sooner, he would have used Sasuke instead of Obito.
 * Obito takes 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 are never made clear.