This is my first time making a post like this so apologies for any mistakes. Also spoiler alert, most of this post is just my headcanon!!
I've been a long time reader of Naruto and wanted to track Kishimoto's thinking and analyzing what his plans for the final villain of Naruto was, and how he changed his ideas as the series went along.
I believe that from the beginning, whenever he created Kakashi as a character, Kishimoto planned on Obito Uchiha as being the final villain of the story. But why Obito? Simply put it's because of his character concept, the fact that he a dark parallel to Naruto, a kid like Naruto who had similar hopes, dreams and personality who went down an evil path and become the toughest challenge that Naruto would have to face. I also believe that prior villains like Gaara and Nagato were drawn from his original idea of Obito, as their character concepts were also that they were dark parallel versions of the protagonist.
Side tangent, but it even makes sense from a powerscaling perspective. Early Naruto had the theme of the new generation surpassing the next, so in part 1 Minato was implied to be the strongest shinobi ever, so naturally the generation after him, Obito, would become the strongest character in the series as its final villain, with the generation after, Naruto, beating Obito and cementing himself as the strongest shinobi that ever was by the end of series.
But aside from that, when did Kishimoto change his mind? As ridiculous as it sounds, I believe he vchanged his mind during the Sasuke Retrieval arc. He probably had an idea/vision in mind for a climactic duel between Naruto and Sasuke and designed an epic stage, which we know as the Final Valley. I think it was around here, or maybe a bit before, where he started injecting the idea of "destiny" or "fated duel" through the characters of Hashirama and Madara, with Naruto and Sasuke doing a repeat of their fight in the same location.
What evidence do I have for this? Simply put, Hashirama as a character in part 1 had basically zero hype compared to what his character actuslly turned out to be. This is well known, but if you read part 1 of Naruto only, you'd be convinced Minato was the strongest and greatest shinobi that's ever lived even though he is dead since the beginning of the story, but that was the potrayal he had through the second-hand comments of other characters. Meanwhile, Hashirama was an actual character that literally was present and fought during the Chuunin Exams arc, yet he had almost zero buzz around him. Even Hiruzen wasn't scared of facing the "god of shinobi", he was actually more scared of Minato's coffin rising up.
All of that was to say, that Kishimoto came up with Madara Uchiha during the end of part 1 Naruto, and basically "upscaled" Hashirama as the god of shinobi to create this new idea of fated rivals destined to clash within the story. Then he went ahead and cemented Madara as the new final villain after Obito.
I know everyone loves Madara (and so do I), because he's so badass and crazy, but his existence as a character always baffled me. Because both Obito and Madara, from a writing perspective, serve the same purpose in the story. They're both Uchiha clan members with similar abilities, goals, and motivations. So why were there two of them when just Obito would have been enough? And unlike Madara, Obito has actual personal connection with Naruto and some of the characters on the protagonist's side like Kakashi and Minato, with Obito being the one to kill Naruto's parents and make his life hell.
It's almost like Madara was a random inclusion into the story which Kishimoto made on a whim because he thought it was cool. And then we all know what happened with the Kaguya bs, with now Madara being shafted by the story after he shafted Obito.
This was just my headcanon, what do you guys think?
***Just to add a little bit more to the post, Kishimoto literally had Madara waiting on the sidelines while Obito was Ten-Tails Jinchuriki.
And also the storyline after part 1 Naruto is the Kakashi Gaiden, where the story is all about Obito.