The Giant Impact Hypothesis states that Earth was indirectly impacted, a deep glancing blow, by another planet referred to know as Theia. Massive debris flew everywhere with most of it falling back down to the now apocalypse going on the surface of Earth. Some material would stay in space though. The material that was flung far enough to avoid falling back while still stuck by Earth's gravity would begin to merge together. Eventually this would form what we know as the moon today.
It is hard to say exactly (geological terms) when this event happened but it would have to be close to Earth's creation but far enough away for most of the Earth's iron to submerge to the core. While there is some iron on the Moon, the core is believed to be lacking in iron. This equates to maybe 4.4 billion years ago.
Like all scientific theories this one is subject to being taken as truth until the next best theory comes around. But signs do point towards this idea being the one that actually happened.
The Moon has long been thought as a dead rock that floats in the sky. I; however, view it as the only landmass visible from any point on the Earth that came from the most active period of geomorphic creation since creation.