I think tobi is an former konoha ninja from tha uchiha clan (maybe obito) that by some reason goten crazy and turned against the vilage and left it. Then with some crazy jutsu he absorbed Madara's powers.