Eye of the Moon Plan

The, though originally designed by Madara Uchiha as his ultimate plan to create an idealistic world, it was in actuality part of Black Zetsu's secret initiative to revive Kaguya Ōtsutsuki. The plan (Madara's vision of it) was later adopted by Obito Uchiha upon the end of Madara's natural life. With the Allied Shinobi Forces considering this as nothing more than robbing humanity of their free will, they intended to fight against its completion. This led to the declaration of the Fourth Shinobi World War. After many losses, the Allied Shinobi Forces eventually won with the efforts of the original Team 7 and the reformed Obito while both Kaguya and Black Zetsu were sealed for all eternity in a newly created moon.

The Plan
Madara created the plan by studying his distant ancestor, the Sage of the Six Paths. He resolved to gather the nine tailed beasts and merge them with the Demonic Statue of the Outer Path in order to revive the Ten-Tails. Then, he would become its jinchūriki and use the flower on its true form to reflect its eye onto the moon, which had previously served as a container for the Ten-Tails' body, and shroud the world in an. This scheme would result in Madara's ability to manipulate every living creature, ceasing all conflict but at the cost of purging free will itself from the world.

Obito's Part
Due to his poor health and old age, Madara could no longer work on the plan at some point, and left its completion and his will to Obito Uchiha who Madara had found badly injured and also near death while being crushed by a huge boulder while on a mission with his fellow team-mates, Kakashi Hatake and Rin Nohara. In order to compel Obito to join him, Madara secretly orchestrated the death of Rin, a girl who Obito also secretly loved with Madara using the opportunity as a way to create darkness within Obito's heart, and then manipulate that darkness to bring the young Uchiha to his side. Obito would then join and take control of the Akatsuki after Yahiko's death, though most of its members were unaware of the organisation's true objectives. Posing as Madara, Obito ensured that Nagato, the figurehead of Akatsuki, would revive Madara with the Outer Path — Samsara of Heavenly Life Technique when the plan finally came to fruition at the cost of the latter's life. Nagato merely believed that they were collecting the tailed beasts in order to create a powerful weapon that would utilise mutual destruction to ensure peace. Obito's personal ambition for the Eye of the Moon Plan is to remove the agency of all living creatures and create a reality without war or suffering. He had also approached Kisame Hoshigaki, requesting his participation in the cabal with the offer of liberating him from the "world of lies"; Kisame, having lived a life tainted with duplicity and betrayal, gladly accepted to abide in the "world of truth" he desired, and along with Obito and Zetsu, became one of the only Akatsuki members to know the truth of the organisation's agenda.

At some point however, Obito had come to disregard Madara's role in this plan, openly declaring that the two of them were never allies. He instead desired to become the Ten-Tails' jinchūriki himself to create his perfect world, and usurped Madara's position as the caster of the Infinite Tsukuyomi. He had planned to use Nagato's Outer Path — Samsara of Heavenly Life Technique on himself should anything happen to him (as removing the seal Madara placed on his heart that prevents him from taking the Ten-Tails into his body is a huge risk to his own life) and when the opportunity presented itself, circumvented Madara and successfully sealed the Ten-Tails within himself.

Madara later noted that had Sasuke Uchiha been born before Obito, he would have used Sasuke instead.

Madara's Insurance
Despite his need for Obito to carry out the majority of the legwork for his plan, Madara set up a number of contingencies to ensure the plan would proceed exactly as he desired. He placed a seal on Obito's heart and created Black Zetsu for the sole purpose of forcing Obito to comply with Madara's revival. Should Obito decide to not bring the deceased Uchiha back, the seal would prevent Obito from becoming the Ten-Tails' jinchūriki in his place and Black Zetsu would possess and compel whomever possessed the Rinnegan to use the Outer Path — Samsara of Heavenly Life Technique to bring Madara back. As the original creator of Zetsu, Madara could communicate with all of his clones and give them directions, furthering his goals without requiring effort on his part. Madara was also very adaptable with the endgame of his plan, as in the event he was revived in a form that could not become the Ten-Tails' jinchūriki, he could manipulate the Zetsu cells in Obito's body to force him to act as he wished anyway to get his plan back on track.

Black Zetsu's Agenda
While Madara thought he had created Black Zetsu as a means of ensuring that the plan would succeed as he envisioned, it later turned out to be a grievous error on Madara's part, as Black Zetsu had been originally created from Kaguya Ōtsutsuki's will, and had simply feigned being born from Madara in order to use him as a pawn, just as Madara had used Obito. It was because of Obito's sudden attempt to hijack Madara's role as the caster of the Infinite Tsukuyomi that Black Zetsu showed Kabuto Yakushi the corpse of Madara, in order to ensure that Madara would be revived to take the role, as it is necessary for him to become the vessel for Kaguya's revival. Furthermore, the Infinite Tsukuyomi, which is to be used in combination with God: Nativity of a World of Trees to ensnare the victims, does not ensure an eternity of blissful dreams as both Madara and Obito had hoped. Rather, it would now actually be used to drain the affected victims of their powers, which would leave them husks of their former selves until they all turned into White Zetsu (who would later become ideal soldiers for Kaguya), while also regathering the chakra into Madara's body in order to bring Kaguya back to the world of living. In short, both Kaguya and Black Zetsu are the true benefactors of the Eye of the Moon Plan.

Progress of the Plan
Though Obito obtained seven of the nine tailed beasts, only the final two tailed beasts: the Eight and Nine-Tails, remained out of his grasp. After Nagato's death ruined any chance of Madara's resurrection and Sasuke Uchiha's failed attempt to capture Killer B provided him with a fragment of the Eight-Tails' power, Obito decides to take Madara's place in the Eye of the Moon Plan. Discarding all caution and revealing himself, Obito arranged to place Sasuke and his team at the Kage Summit in hopes the ninja leaders would be weakened enough to be easily taken hostage to negotiate their freedom in exchange for the last two living jinchūriki, Killer B and Naruto Uzumaki. This, however, ended in failure, due to Danzō Shimura escaping during the chaos while combined forces of the Kage, their bodyguards, and Mifune overwhelmed Sasuke. Sending Sasuke into the other dimension with Karin, Obito introduces himself as Madara while revealing this plan to the four Kage. However, they refuse to hand over Killer B and Naruto while creating the federation of the Allied Shinobi Forces to prevent Obito from achieving his Eye of the Moon Plan.

At the end of the first day of the Fourth Shinobi World War, Obito stole the Kohaku no Jōhei and Benihisago that each contained one of the Gold and Silver Brothers, and having already fed the Eight-Tails' tentacle to the Demonic Statue, intended to put the plan into motion by the end of the following day. Madara's resurrection through Kabuto Yakushi's Impure World Reincarnation disrupted Obito's deception, and when engaging Naruto his mask was shattered, revealing his true identity. Obito fed the Kohaku no Jōhei and Benihisago to the Demonic Statue in order to revive an incomplete Ten-Tails, claiming that the monster would still have enough power to be sufficient in completing his plan. Once joined by Madara after he defeated the Kage, Obito is berated for deviating from the original machination due to the Ten-Tails' revival being incomplete and his own revival through a different method. Regardless, entrusting Obito to make sure no one interferes as he battles Naruto and Killer B, Madara decides to capture the Eight and Nine-Tails personally to complete the plan while there is still time. Though Naruto and Killer B made an attempt to destroy the Demonic Statue with a giant Tailed Beast Ball, they were unable to stop the Ten-Tails' revival.

Though he attempts to control the Ten-Tails by having himself and Obito use Hashirama's DNA, Madara notes that the monster is beginning to resist control. Because he was revived by Impure World Reincarnation, Madara is only a reanimated corpse and cannot become the Ten-Tails' jinchūriki, which would require him to be brought back as a living body with Outer Path — Samsara of Heavenly Life Technique that only Obito, having obtained his master's Rinnegan, could now execute. However, using that fact as leverage since using the technique would kill him, Obito persuades Madara into letting him use the Ten-Tails to give despair to Naruto and the entire Allied Shinobi Forces. However, it had the opposite effect as Naruto and his comrades manage to sever the means that the Uchiha used to control the Ten-Tails with Obito temporary sent to other dimension while uncontrolled colossus begins to rampage on the battlefield. It was only once Obito returned that Madara callously activated the chakra receivers inside Obito's body to force him into using the Outer Path — Samsara of Heavenly Life Technique. However, Obito never intended for that to happen and overcomes Madara's control to seal the Ten-Tails inside his own body, thus becoming its jinchūriki. Not long after restraining the beast and taking full control of its power, Obito transforms Ten-Tails into its tree form to complete the Infinite Tsukuyomi. In retaliation, Madara intends to stop Obito before the completion and take his place by using Hashirama Senju's sage powers.

The plan is interrupted when Naruto, B, Sasuke Uchiha and the rest of the Allied Shinobi Forces pulled out all nine tailed beasts' chakra from Obito's body, preventing the tree from blooming. After that, inside his subconscious, Obito is assaulted by fleeting visions of an alternate future based on if he never took up the Eye of the Moon Plan, and started to conclude that he is subconsciously regretting his actions affiliated with the plan.

Following Obito's defeat, with the aid of Black Zetsu controlling the former to perform the Outer Path — Samsara of Heavenly Life Technique, Madara finally revives himself and steals Hashirama's Sage Mode to acquire his healing techniques and fight against the nine tailed beasts. Upon receiving his right eye, Madara knocks down the tailed beasts, restrains and seals them into the Demonic Statue of the Outer Path to initiate the plan once again. Shortly afterwards the Ten-Tails is revived and Madara seals it inside himself and then tries to get back his left eye. However, Obito escaped to the other dimension. Madara then had to fight Guy and later had to fight Naruto and Sasuke before getting his eye. When the odds were against him, he made a diversion and took Kakashi's eye with which he went to the other dimension. After taking his eye from Obito, he returned with the help of Black Zetsu. After showing off his new power with both eyes, he awakened a third eye on his forehead similar to Kaguya's eye with which he completed the Eye of the Moon Plan and cast the Infinite Tsukuyomi.

Once Madara cast the technique onto the moon, its light instantly spread throughout the entire planet, turning it bright as day and making escape impossible. Every living being in the world fell for the eternal genjutsu, and Madara then used God: Nativity of a World of Trees to bind the entrapped population to the holy tree, essentially assimilating everyone into one being. The only ones unaffected are the four reincarnated Hokage, the Zetsu (Obito to whom Black Zetsu is attached to) and the four members of the original Team 7, the latter being protected by Sasuke's Susanoo, which was strong enough to block out the light of the Infinite Tsukuyomi.

After the light of the Infinite Tsukuyomi dies out, Madara approaches the still standing Team 7, with the intent of killing them so they will not wake everyone from their ideal dreams while Madara also states that he saved this world by turning Hell into Heaven. As Naruto strongly disagrees, angrily calling it nothing more than living a lie, Madara insists that it's all over and that Naruto is ruining everyone else's personal peace. However, before either side can fight, Black Zetsu uses Obito's left hand to pierce through Madara's chest which leaves everyone shocked. As Madara tries to come to terms with this betrayal while insisting that Black Zetsu is his will, Black Zetsu reveals that he is not Madara's will, but actually that of Kaguya, calling Madara "presumptuous" for believing that he himself is different than anyone else, even Obito. With that, Black Zetsu takes over Madara's body, causing it to bloat and absorb chakra at overloading levels, until the body returns to a smaller size. In Madara's place is a fully reborn Kaguya, while Black Zetsu who begins draining Naruto and Sasuke's chakra reveals his machinations of historical events which led to the current conflict between the Uchiha and Senju clans while manipulating Madara which was all for the sake of completing the Eye of the Moon Plan which would in turn lead to Kaguya's revival with Black Zetsu revealing that the victims caught in the trap would not be trapped in a paradise where they could lead their own ideal lives for eternity. Instead, they would be eventually drained of their powers and become White Zetsu, ideal warriors for Kaguya's army.

Ultimately, despite the casting of Infinite Tsukuyomi and Kaguya's resurrection, the Eye of the Moon Plan is foiled when Kaguya is resealed with the help of Hagoromo Ōtsutsuki's power being lent to Naruto and Sasuke, and the combined efforts of Team 7 and Obito, although he dies during the final battle, sacrificing himself to take a fatal blow originally intended for Kakashi.

Kaguya is eventually resealed in the Six Paths — Chibaku Tensei much to Black Zetsu's disappointment although Black Zetsu attempts to bind its time so that it can bring Kaguya or its "mother" back a second time in the future to start all over again. Naruto, on the other hand, not willing to let history repeat itself a second time catches Black Zetsu and after calling him a snot-nosed brat too afraid to leave its mother's side, sends it into the growing satellite to seal it as well, resulting in both their threats being eliminated forever and also ironically granting Black Zetsu its long-wanted wish of always wanting to be at its "mother's" side. The new moon is soon left isolated in the sky of Kaguya's core dimension while the tailed beasts have been extracted, and everyone else has been summoned back to the outside world when Hagoromo calls for the spirits of the previous Kage to cooperatively assist. After Naruto and Sasuke's final battle ends, the two end the Infinite Tsukuyomi together and free all the people trapped in it, which also kills any remaining White Zetsu as they are also victims of the genjutsu.

Trivia

 * Obito has blamed Naruto for the plan's slow progress, due to his constant interference causing him to deviate from the early parts of plan as Madara envisioned. He ultimately intended to become the Ten-Tails' jinchūriki instead of Madara.
 * Obito noted that he had thought of synchronising Sasuke Uchiha with the statue. However, Obito had likely dropped this idea due to how Madara was reincarnated already by Kabuto.