Evolution of the universe predates both the chemical evolution and the evolution of life. In this lecture, Harry J. Lehto, Professor in the Dept of Physics and Astronomy in the University of Turku, Finland, summarises the origin of the critical elements for life, the CHNOPS, and the initial formation of molecules.
From cosmological models we can understand the origin of hydrogen and helium. Later hydrogen will be required when water is formed. Helium, which appears quite useless for life, turns out to be a critical factor in the synthesis of carbon leading to heavier elements. The second compound of water, oxygen, is formed in the hot cores of stars.
Once these elements get from the stars back into the cool interstellar space they begin forming interstellar clouds, where a vast spectrum of molecules is formed.