How were the planets created?
Scientifically: At the beginning of this universe there was all just drifting gasses. Through millions of years this gas eventually began to spiral around one point and get compressed into a giant ball. As the giant ball of gas cooled it became a solid planet. It would be millions of years later until it contained life.
Biblically: God created Earth and all its inhabitants in 6 days and rested on the 7th.
Planets and moons remain in their orbits because of the gravitational pull other bigger planets or stars have on them, for example the Earth stays in its orbit because of the gravitational force it is subjects to created by the Sun, and the moon stays in its orbit because of the gravitational force it is subject to created by the Earth. It's all about gravity and force.