That's like saying Akatsuki was introduced to make Naruto stronger
Dude. I'm tired of people who fail to comprehend the easiest things and do silly comparisons.
In a way, yes. They were there to make Naruto stronger. Everything Kishimoto did was there to make Naruto strong, leading him to the title of a Hokage.
But unlike Kaguya, Akatsuki had some real, well-developed background and gave the manga a global scale. Like "not everything is about Naruto and Konoha". The world felt much more alive.
Kaguya was never there. She as well as Hamura and all the other Ootsutsuki except Hagoromo, were never mentioned. of course Kishimoto came up with them in the last chapters in Naruto. You are naive if you think that Kishimoto planned Kaguya and her alien-race before like... the mid of the war arc.
The entire Naruto-story was re-written just to find a half-baked way to introduce a character even more powerful than anyone, so he make a legit ending. Let's be honest, Madara was too much overpowered. Naruto and Sasuke would've never beaten him.. but he couldn't let his manga end with a successful villain. So he replaced his undefeatable, smart villain with a much more powerful but unbelievably stupid villain. Easy game for the heroes and welcome to a happy ending.
Oh and another reason why Kaguya was there:
That expandable plot-opportunity kept the cash-cow alive. It's all about the money.