Astronomers do not know for certain, but the best guess is that as the formation of the Earth was winding down, it was being bombarded by larger and larger 'planetessimals' hundreds of kilometers in size. The direction of spin of the Earth today, may have been the result of a collision with a very large body which re-set the axis of the Earth to point far from the axis of the over-all solar nebula which we now see as the plane of the solar system's 'Ecliptic'. We think that the last major impacts with a body 1000 kilometers across, not only tipped the Earth to its present inclination, but tore a chunk of material out of the Earth, and formed a ring around our planet which later became the Moon. The impact re-vitrified the entire surface of the Earth perhaps 4 to 4.5 billion years ago. It is amazing that the first fossils are present in rocks 3.8 billion years ago, suggesting that life was hell-bent on forming on this planet so soon after it had suffered a catastrophic impact.