Madara's role in creating 'Tobi'.
This may sound nore convoluted than it actually is, I'm not suggesting Madara is Aizen. Now, to discuss this we have to understand the reason why Rin was killed in the first place. I would like to direct your attention to a thread by Centipede on this that has put it better than I ever could.
Now, personally, I think Rin was an involuntary spy more than anything, that ended up there as a child, that's why she was buried in the leaf village, but a spy from the Mist nonetheless. The era the Mist was in at that point was the bloody Mist, and as we know, the Mizukage was being controlled, by an Uchiha with extraordinary genjutsu prowess.
We also know that when we last saw Madara alive, he had an eye that didn't belong to him, as he had given his real eyes to Nagato
We can infer from the manga that close family members have similar mangekyo sharingan abilities, making their implantation for the EMS possible. Ao compared Kotoamatsukami to the genjutsu used to control the Mizukage, and only the family member of Shisui we know is Kagami.
Now, we have no idea when Kagami died, but I don't think he lived to old age, as he definitely would have been on Hiruzen or Danzo's council if he was. I think Madara killed him (before he gave away his eyes obviously), and then took the eye for himself. We don't know if Kagami had MS but if he did, chances are, it would be something similar to Shisui's, allowing him to manipulate the Mizukage.
Madara, then would have been the one to usher in the Bloody Mist era, and would have had a role in creating an involuntary spy like Rin Nohara. Even if it was the previous Mizukage who had done this, as Madara was in charge, he would have known about this plan. When Obito 'slipped through', (I still don't know what the **** that's all about), and started screaming about protecting Kakashi and Rin, he saw an opportunity.
As we have seen with KA, the eye doesn't have to be visible for the genjustu to work and for and Uchiha with senju DNA like Madara, using a technique like that wouldn't have been too hard, and yes, he was attached to a statue during his later years, but it could be like Kyoka Suigetsu where you see it once and he can manipulate you where ever he is, without you knowing. Madara didn't know Kakashi, but he would have been aware of Rin, and the Uchiha being the emotional people they are, Madara would have known that attacking them may have swayed Obito to his side, as he had been with him for several months before the attack occurred. This would explain why he was so sure Obito would be back.
However he also knew how the shinobi world worked, and how stupid it really was, better than anyone, so he knew that Kakashi would have to kill Rin. This would serve to make Obito understand where he was, a world where there are 'winners and losers' where people become sacrificial lambs for the 'greater good', just like the Uchiha, Itachi, Rin, the White Fang etc. After this and Obito getting Nagato on board, I'm assuming Obito carried on using the Mizukage, and Kisame recognised him for this reason.
In conclusion, I believe Madara used Kagami Uchiha's eye to control the Mizukage, and orchestrated or at least knew of Rin's role as a spy, and when he saw how much Obito cared about his comrades, he used an attack on Rin and Kakashi to get Obito to understand his vision of the shinobi world and the positives of the moon's eye plan.