Known as the "Ghost of the Uchiha" in Naruto, Madara Uchiha was a legendary shinobi from the Uchiha Clan. As a young boy, he befriended another child known as Hashirama Senju. The two grew up to be astoundingly powerful shinobi and together founded the Village Hidden in the Leaves.
However, a difference in ideals led to Madara walking a path separate from that of his dear friend. A series of events led to a dispute between the Senju and Uchiha Clans, and Madara took on Hasihrama at the Final Valley in a battle of immense proportions. The battle ended in Hashirama's favor, with Madara faking his death and going into hiding.
Years later, during Naruto's Fourth Great Shinobi War, when he returned to battle, something was different about him. As his armor was ripped off, there seemed to be a face on the left side of his chest that resembled Hashirama Senju.
Naruto: The reason for a face on the left side of Madara's chest
During the battle at the Final Valley in Naruto, Hashirama Senju emerged victorious. Both parties sustained injuries, but Madara decided to fake his death and go into hiding after reading the situation. But, while fighting, he bit off a small piece of Hashirama's flesh.
Retreating to his hideout, he threw up the piece of Hashirama's flesh that he had bitten off and later implanted that piece into his wounds. By doing so, he combined the powers of the Senju and the Uchiha. This gave him access to Hashirama's abilities and also awakened the legendary Rinnegan.
As this was revealed during the war, Madara spoke of "an acquaintance of an underling" who showed him that it was possible. Given the facts, the only plausible explanation for who this acquaintance in Naruto can be is Orochimaru. At the time, Madara did not know who Kabuto was, so he was ruled out. The said underling could only be Obito Uchiha.
Knowing Orochimaru and his obsession with experimenting, he likely introduced the idea to Madara, and the two proceeded with the experiment. As for why a face formed, that still remains a bit of a mystery, probably hinting at some genetic reaction between the cells of the two shinobi.
What happened to Madara's Rinnegan?
Towards his old age, Madara became aware of his declining power. So, he took Obito as his successor. Before dying, he instructed the boy to implant his Rinnegan into Nagato for his eventual revival years later.
After his death, Obito carried on Madara's legacy, using his knowledge to strongly influence and control the Akatsuki behind the scenes. He even acted as Madara himself for quite a duration of the story. True to the plan, in the final stages of it, Kabuto aligned himself with Obito and used the Reanimation Jutsu to revive the corpse of the Uchiha.
Final Thoughts
Madara Uchiha was a formidable power who greatly troubled the Allied Shinobi Forces during the war. He succeeded in his plan to revive himself, along with gaining the powers of the Senju and awakening the Rinnegan. However, he, too, was a pawn in the grand scheme of things as Kaguya Otsutsuki took over his body to return to the shinobi world.