How was the earth created?
Accretion of matter.
There are a couple of theories of planetary formation. The most commonly accepted one is that the same inter-stellar materials that coalesced into stars also formed the planets that orbit the stars.
Specific planetary rock/element ratios indicate that the planets are probably formed from other materials ejected from expiring stars (novas). These can become trapped in orbits around other stars, and then gravitationally accrete to form the larger bodies.
Moons are smaller bodies that are held by the planets in their own orbits.