Every 23 hours, 56 minutes, and 4.1 seconds, the Earth spins once around its axis. We usually call this a day and just round it out to 24 hours with some leap seconds/years tossed in on occasion. However, Earth is not the only thing spinning as it careens through space. Almost every celestial object like stars and planets are spinning. Whats more interesting, almost everything within the solar system spins and orbits in the same direction. The planets are dancing a seemingly choreographed waltz through space, but why?
To answer the question we have to go back to the beginning, to the formation of a solar system like ours. Before a star and its planets exist, theres just a cloud of disorganized gas and small molecules. This is often called a molecular cloud or stellar nursery. The Eagle and Orion Nebulae are some of the more famous stellar nurseries we have been able to observe with the Hubble Space Telescope.
These clouds are composed mostly of molecular hydrogen, which wouldnt be able to congregate outside the dense molecular clouds. These clouds can be of any size not just massive structures like the Orion Nebula. Over time the energy of the molecules in the cloud pushing outward can be overcome by slower molecules collapsing together farther in. As long as there is sufficient mass in the molecular cloud, it continues collapsing in toward the center until it reaches a high enough mass to fuse hydrogen and become a new star.
The spin that we see quite clearly now is related to the process of the molecular cloud collapsing. The original cloud was very, very large and made up of many individual molecules and small clumps of matter. On that scale, there is some small amount of rotation within the cloud. It could be caused by the gravity of nearby stellar objects, local differences in mass as the cloud churns, or even the impact of a distant supernova. The point is, most molecular clouds have at least a little rotation.
As the cloud collapses to form a star, it has what physicists call angular momentum. This is the movement an object has as it rotates around a central point. In a large system like a molecular cloud, each particle has some angular momentum, and it all adds together across a very wide area. Thats a lot of momentum, and it is conserved as the cloud continues to collapse. But how does that get us to objects that spin and orbit?
Imagine a figure skater spinning around with arms outstretched. That is a model of angular momentum just like a collapsing cloud of gas. When the arms are drawn inward, the rotational velocity goes up because the total angular momentum is conserved unless there is some external force acting on it. There are such forces acting on the figure skater, but less so on a collapsing molecular cloud.
So if a molecular cloud was maybe a light year across, then collapsed down to be just a fraction of that, it would be a huge change in size. Just like the figure skater pulling her arms in, the velocity must increase to conserve angular momentum and therefore form a spinning protostellar disc. It is from this orbiting matter that all the planets form, and of course, they are also spinning and orbiting in the same direction because of the conservation of angular momentum.
There are two outliers in the solar system which seem to break the rules about conserving momentum Uranus and Venus. Uranus spins on an axis of almost 90-degrees (on its side). Venus meanwhile spins the opposite direction as Earth and the other planets. In both cases there is strong evidence that these planets were struck by large objects at some point in the distant past. The impacts were large enough to overcome the angular momentum of the bodies, and give them a different spin.
The tl;dr here is that almost everything in the solar system is spinning because the matter it is made of was always spinning in some small way. That kind of momentum doesnt just go away. There is no force that makes planets rotate or orbit its just the energy from the formation of the solar system still being expended.
Now read: Geek Answers: Why do objects burn up when entering the atmosphere?