I have a theory that basically states that Hamura was sealed along with Kaguya due to the characteristics of the sealing technique they used against her (Hamura had to be sealed with her as part of the jutsu. It could've been Hagoromo but Hamura offered instead). After being sealed with his mom, Kaguya managed to somehow impart some knowledge or something to Hamura that made him change his mind on her. He managed to escape and thus the history of Naruto manga. Also, what knowledge could cause Hamura to suddenly side with his mother? Aliens.
Kaguya is actually from another planet. This planet is the one Naruto and Sasuke are on. It looks like this because it was destroyed, destroyed by the same beings that are now traveling to Earth after all these years. Kaguya managed to escape her planets destruction where she ate the God fruit on Earth to become stronger.
Or... I'm just on crack.