It was rather obvious that Madara was not going to be the final villain of the series. Even taking the Tobidara route of a part 3 where Madara is still alive - his role may not be that of a villain.
Dealing with the manga, however, Madara was shown to be a complete puppet. He took off on a rampage, creating the very disaster he was using to justify his efforts in the first place, because he read on a tablet something about a paradise world of hypnotism.
Rather than thinking about this critically, or bringing this up with anyone else (even his own clan, apparently), he just goes complete renegade, starts a coupe, abandons his clan, throws the villages into chaos and gives Black Zetsu the platform to destroy the Uzumaki village and destroy their knowledge, etc. If Madara had been even the least bit skeptical about the information he was receiving before committing to an action of no-return, then events in Naruto would have been very different and the Ninja world would likely have been far less violent on the whole.
Madara was his own final adversary, and lost. His story is, ultimately, a story of tragic and ironic failure in spite of success. Every gain he thought he made was, in reality, a loss. By the time he stood at the end, he fought against a united world of Ninja, killing countless numbers of them and nearly destroying the world, in an effort to enact a plan for 'world peace.' The Madara at the end of Naruto is the foil for the Madara in the pre-history of Naruto. He's his own hero and his own villain - unable to recognize, even when it is literally kicking him in the teeth, the result he has strove so hard for. From a kaleidoscope vision to tunnel vision. From a man who loved his brother to a man who would steal his brother's free will and end his life with all others.
Intelligent people can be foolish. Smart people can be deceived. If we look at the characters as messages, more so than actual people, then Madara's is the warning that all of the smarts, all of the knowledge, and all of the ambition in the world do not make you invincible. That... and be careful how much stock you place in ancient secrets.
Compare and contrast.
"I read the ancient stone tablet. Kaguya, sage, brothers, curse of hatred that I fully intend to act in accordance with, yadda-yadda, I know many things."
"Some say that the Sharingan is a devolved form of the Byakugan."
Which one more accurately depicted the villain hierarchy? In spite of his very privileged access to an ancient secret, that ancient secret was designed to steer him into a pre-determined path, and completely omitted the idea that there was more to be discovered about the Hyuuga.
But, I am rambling at this point.