Why was the matter that formed the earth spinning? Why does everything in the universe, from galaxies down to atoms, spin?
Wow, what a neat question. I think it is related to the effect that we have seen when a skater who has arms extended and is slowly spinning suddenly pullls the arms into the body surface. The result is that spin rate increases. To even spin faster the skater will be standing straight with the arms up over the head. This makes the distributions of mass as close toe the spin axis as possible and makes the spin as large as possible. The main idea is that angular momentum is conseved ie. cannot change. Angular momentum is the product of the spin rate and the moment of inertia ( a measure of the distribution of the mass about the axis of rotation) The product is constant. If mass is widely dispersedas before condensing into a planet, and is very slowly rotating, then when it condenses into a planet (making a small moment of inertia) the rate of rotation could be large. So condensing amplifies whatever rotation there was initially. Now, what are the chances of something not rotating exactly before it condenses? Apparently, very small since everything seems to have some rotation. I am not sure this gets to your question of why, but it has been a great question to think about.
http://www.newton.dep.anl.gov/askasci/ast99/ast99318.htm