There are two theories, but the most logical one is the crash theory.
Trillions of years ago when the Earth was still a chunk of molten rock, a huge asteroid collided into the surface, taking a huge piece of our planet flying into space. The Earth's gravity pulled the material into orbit around it, and due to the universes gravity, the chunk molded into a sphere-like shape, and has been the moon ever since.
The least logical theory is the asteroid theory.
An asteroid nearly collided into Earth, and the gravitational pull from Earth and was orbiting our planet since.