Re: How did Uchiha Madara give tobi the rinnegan ?
My best guess is that Madara lived to be around 90 - 100.
He probably just barely survived fighting Hashirama and seemingly pulled an Orochimaru.
Notice when Madara is revived, he mentions "He was able to revive me like this", implying he was obviously in some different state when he died.
Many years on, he somehow activated his rinnegan, most likely something to do with the war going on at the time and transplanted them to Nagato (my guess is Nagato is somewhere between 30 - 40, as Yahiko himself died some time ago yet Choji mentions that he looks around 25 - 30).
Several years later, he came across Obito and took him in, healed (possibly with zetsu clones), trained, taught him everything he knew and left his will to Obito.
[Evidence he was alive to have known Obito]