Here is a very cool video on how the moon was formed 4.5 billion years ago. NASA has been able to better understand the formation of the moon due to the data and images sent by the Lunar Reconnaissance Orbiter (LRO).
A Mars-sized object crashed into Earth & this collision threw clouds of debris into space, which clumped together to create the moon. The craters we see today were formed by erupting volcanoes and giant asteroid collisions.
Credit and copyright: NASA Goddard Space Flight Center