The Earth, like the other planets in the solar system, rotates due to the manner in which it was formed. Earth inherited its rotation from the spinning movement of the accretion disk, or formation of material moving around a large object, from which the solar system was formed.
The formation of the solar system occurred 4.6 billion years ago when a huge cloud of dust and gas began to collapse under the weight of its own gravity. As it collapsed, the early solar system began to flatten out, forming a large spinning accretion disk. The planets were formed as material within this disk gathered closer together. The Earth continues to spin upon its axis because there are no outside forces acting to stop its rotation.
Scientists believe that a large object, approximately the size of Mars, once collided with the Earth in the distant past. This collision occurred just 30 to 50 million years after the formation of the solar system. The resulting impact slowed the rotation of the Earth and ejected enough material from the surface of the planet to form the moon. Prior to this collision, the Earth had a much faster rotational speed, with a single day lasting only about six hours.