http://en.wikipedia.org/wiki/Earth
and this info
Birth of the Earth
Initially, scientists thought that the Earth was formed by a gentle 'rain' of dust and small particles slowly accumulating on the then small Earth's surface. And after a while it would have began to heat up due to the slow decay of radioactive elements, and melt, forming a bouyant crust and dense core. However modern views lean more towards the theory that the Earth grew relatively quickly (100,000 years to 1 million years rather than 100 million to 1000 million years) through larger collisions. The Earth was probably molten, or at least partially, through its period of growth, allowing heavy materials to sink towards the centre, forming 'cores' and lighter ones to float to the surface. This process is called differentiation.
Many astronomers currently believe that slightly less than 4,500 million years ago, whilst the Earth was still hot and young, a massive, violent off-centre collision with another large object led to large amounts of material being ejected into the Earth's orbit. This material cooled down and formed what we know as the Moon a few years later. According to this hypothesis, the core of this unknown object would have been incorporated into the Earth's mantle, thus changing the Earth's composition.
from
http://www.solarspace.co.uk/Earth/earth.php