Well, actually, there have been several theories over many decades. Earlier versions of lunar formation theories included capture, where the Moon would have been a strayed planetoid. Another version was fission, where the Earth was spinning so fast that it would have ejected out of the Earth and then formed its own body.
This led to our current theory, the giant impactor theory. So this collision was during the late stages of planetary formation throughout our entire solar system, when planets were still very new and very much forming. So this happened when Earth was just an embryo — a baby planet, and this was actually in a crash course collision with Theia, which is a Mars-size planetoid. And this collision ripped apart early Earth’s crust. And that crust then coalesced. It snowballed into a wholly separate entity, which we now call the Moon.
So where did our Moon come from? Well, currently, our understanding is that the Earth had collided with a Mars-sized object named Theia. But once we send future astronauts to the lunar surface again, who knows? We may actually have a whole new theory in the coming decades.