That’s an interesting question but one for which there is currently no real answer. There are lots of ideas as to how the basic chemical components necessary for biology to evolve came together. Most astronomers now think that processes on icy dust grains made the basic chemicals which we deliver to Earth on comets. This was supplemented by some synthesis in the primordial environment. How these simple chemical came together generate life remains an open question. Take a look at https://simple.wikipedia.org/wiki/Origin_of_life to get a feel for problem and what people are doing to try and answer your question.
Comments