Outer space is not empty space. The interstellar mediumAll the gas and dust found between stars. (ISM) is the name for the stuff that is in space between stars in our Milky Way Galaxy. The ISM is mostly made of clouds of hydrogen and helium. The rest of the ISM mostly consists of heavier elements like carbon. About one percent of the ISM is in the form of dust.
Stars form in regions of the ISM that are dense enough for gravity to pull the gas and dust together to make compact, hot spheres. These protostars eventually become so dense and hot that nuclear fusion begins, and they become stars.
A simulation of the Veil Supernova Explosion.
Credit: ESA/Hubble (M. Kornmesser & L. L. Christensen).