Why do earth rotate and revolve ?
Because of gravity.
All objects, such as stars and planets, in the universe began from the collapse of dense interstellar clouds. Interstellar clouds can be as huge as thousands of light years across, but as the clouds in certain areas become denser than other, the gravitational force increases, causing the surrounding gases to collapse in on the denser part.
As the gases collapse, fluctuations in density of the interstellar clouds imposes a resultant angular force on the central body. This produces an angular momentum, causing the central body to rotate. Angular momentum is given by Angular Momentum,
When a interstellar cloud with the size of a few light-years shrinks to the size of a solar system, the decrease in radius is huge, which is why the angular momentum is also huge, and the resulting star and planets rotate very fast.
The planets that were formed due to anomalies in the density of the cloud all fall in onto the more massive star, but gravitational force of other surrounding objects like neighboring stars deviate its course, preventing it from falling into the star. The gravitational attraction of the star, however, prevents the planets from escaping, and puts them in a revolution around it.