i dont know
there once sat a giant cloud of gas, many many times larger than our own solar system. for a long time it sat relatively idle, until one day it got a push from a supernova or the wind of a nearby star. that push was enough to make it reach a critical point. there was now a region dense enough that pressure would not be able to stop gravity any longer.
it began to collapse, very slowly. as it collapsed, it became apparent that it had a little bit of extra angular momentum in one direction. and as it got smaller and smaller, it began to spin faster and faster in that direction. this slowed the collapse along that axis, turning it into a pancake shape.
the centre of the pancake compressed the fastest, and began to turn into a huge sphere of gas. eventually the centre of the sphere became dense enough that the temperature and pressure were high enough for fusion to start. this slowed and eventually stopped the collapse of the sphere, and instead light and small particles began streaming from it, pushing away much of the gas and clearing a region around it as it became a star.
at the same time, small regions of heavier materials in the outer parts of the disk became dense enough to collapse themselves, turning into smaller spheres. the bigger ones that formed first were able to bring in huge amounts of gas, while the stragglers only managed to grab a bit.
the star eventually cleared away all of the gas, leaving several huge balls of gas, a few solid rocky spheres and lots and lots of smaller clumps of rock.
as they orbited the star many hundreds of thousands or even millions of times, they interacted with each other gravitationally, until everything had either found a stable place to orbit or had been thrown away into crazy elliptical orbits or into one of the other objects.
everything was pretty boring for the next few billion years as all of the objects settled down and cooled, but eventually life appeared on one of the rocky spheres and in a relatively short amount of time covered it completely. one day, a group of those life forms decided to call it earth.