very slowly! it took a very very long time for all the elements floating around in space to collect together to form a planet. It was all pretty random and just so happened that Earth was the right distance from the sun (which just happened to be there) that it could sustain life!
Comments