According to one of the earliest popular theory put forth by Laplace, which is called the Nebular Hypothesis, earth has been formed through solidification of a ring thrown away by a cooling and rotating nebula (sun). This ring was one of the nine such rings that condensed to form various planets.
But according to a more plausible theory advanced by Jean and Jeffreys called the Tidal hypothesis, the origin of earth was based on the existence of two nebulae instead of one. According to this theory, a large nebula came very close to a smaller nebula (the sun) and its gravitational pull caused a huge tidal upsurge of matter on the surface of the smaller nebula. As the larger nebula moved away from the smaller one, the matter rising in the form of tidal wave from the surface of smaller nebula was pulled towards it and was drawn so much away from the parent nebula that it could not come back to the parent body. However, it could not follow the larger nebula also and as the larger nebula moved away, this matter was detached to form planets.
On cooling, the matter condensed to form the planets. As the matter evolved from sun has an inertial momentum of rotation, so after getting detached from the sun, it conserved its momentum.
Earth rotates upon its axis from west to east. Its period of rotation is about 24 hours i.e., 1 day. Due to this rotation of earth, all the parts of earth get sunlight. Imagine, if the earth wouldn’t have been rotating, then only half of the earth would have received the sunlight. It would have resulted in half the earth as frozen and the rest half as hot. Half of the earth would have no night and rest half, no day.
The earth’s axis of rotation is not vertical. It is inclined and makes an angle of 66 ½o with the plane of ecliptic i.e., the plane of orbit of the earth around the sun.