Interia and gravity combine to make a planet stay in an orbit.
Orbit
an object that moves fast enough can orbit another body in space. As a minimum, to orbit the Earth you need to travel 30,000 kph at 100 km altitude.
There is no evidence that the moon has ever left its orbit since it formed, and there is no reason to expect that it will leave its orbit anytime in the forseeable future.
Nicolaus Copernicus formed the idea of a heliocentric universe, where all planets orbit around the sun.
Earth probably formed by accretion near the same orbit it is in now. Gravitational interaction from other bodies probably caused it to drift to its current orbit.
the moon
It has been orbiting the sun since it was formed.
The strongest wall of the bony orbit is the medial wall, which is formed by the ethmoid bone and lacrimal bone. It provides protection to the delicate structures within the orbit, such as the eyeball and optic nerve.
The galaxy was formed from the attraction of stars which in our galaxy orbit a massive black hole.
The mandible does not make up a part of the orbit. The orbit, or eye socket, is primarily formed by seven bones: the frontal, sphenoid, zygomatic, maxilla, palatine, lacrimal, and ethmoid bones. The mandible, which is the lower jawbone, is located below the skull and does not contribute to the structure of the orbit.
It may have captured or formed moons in the distant past, but none remain. The closeness of Mercury's orbit to the Sun would likely prevent moons from maintaining a stable orbit.
When sea water evaporates it leaves the salt behind and takes the water into orbit