While his intentions were good, Madara ended up going down the wrong path, making him a villain just like Pain. Although both sought peace in their own way, there were times when Madara Uchiha did things much better than Pain, making him a villain in a league of his own.
Does Madara have a weakness?
1 Weakness: Madara Is Reckless And Overconfident In His Own Strength.
Can obito beat Pain?
Obito was truly an incredibly powerful fighter with few being strong enough to hold their own against him. He was far stronger than Pain and his ambition was likely much greater as well.