The most popular theory regarding lunar formation is that a Mars-sized planetoid slammed into the Earth and flung molten debris into orbit around 40 million years after the solar system was created, according to scientists at the National Aeronautics and Space Administration (NASA). This is called the giant impact theory.
Debris from the collision was bound together by gravity, and these ejected particles coalesced to form the moon. Initially, both the Earth and moon spun very fast on their axes, but they have since slowed down. The giant impact hypothesis explains why the moon is made of lighter elements without a heavy core. This mathematical model also explains why the moon's orbit became tidally locked with the same face towards the Earth at all times.
There are two other theories regarding how the Earth's moon formed. One is that the moon was created at the same time as the Earth because particles were coming together during the solar system's formation. If this is true, then scientists believe the moon would be much denser.
Another theory of lunar formation involves the Earth's gravity capturing a moon passing by the planet. This is how Mars got its two moons. Scientists think that if this how the moon came into Earth's orbit, the celestial body wouldn't be spherical nor would the moon line up with the Earth's ecliptic orbit.