One possibility suggested by scientists is called the fission hypothesis.
It states that early in its formation Earth was spinning so quickly that a glob of molten material was thrown off into space. The molten rock was kept in orbit by Earth’s gravity and gradually cooled.
The second idea is called the capture hypothesis, in which a body of material from far off in space came close enough to be grabbed by Earth’s gravity. A combination of the two hypotheses is most likely:
An asteroid’s impact with Earth sent matter flying into orbit, creating a ring around the planet. Over time, the matter came together to make the Moon. But, where the Moon came from is still mostly an unanswered question.