It is theorized that Earth formed as part of the birth of the Solar System: what eventually became the solar system initially existed as a large, rotating cloud of dust, rocks, and gas. It was composed of hydrogen and helium produced in the Big Bang, as well as heavier elements ejected by supernovas. Then, as one theory suggests, about 4.6 billion years ago a nearby star was destroyed in a supernova and the explosion sent a shock wave through the solar nebula, causing it to gain angular momentum. As the rotating cloud flattened out, some of the gas and dust clustered together due to gravity (eventually becoming planets). Because the initial angular momentum needed to be conserved, the clustered mass started rotating faster (much in the same way an ice skater rotates quicker with his/her arms "clustered" closely to his/her body). The current rotation period of the Earth is the result of this initial rotation and other factors, including tidal friction and the hypothetical impact of Theia. Note: this doesn't mention why everything in the universe is moving - quick answer is 'the big bang' as it's been called.