About 300,000 years after the Big Bang light could travel freely across space because electrons were now bound up in atoms and could no longer interact strongly with photons. Matter and energy became decoupled at this juncture and light could travel freely across space.
Today's observable cosmic microwave radiation background is the greatly red-shifted image of this first burst of light. The present day microwave background contains slight temperature irregularities. This indicates that the early universe was not perfectly homogenous. Ancient density fluctuations under the influence of gravity led inevitably the clustering of matter. In this way, the groundwork was laid for galaxy formation.

All-sky picture of the infant universe from three years of WMAP (Wilkinson Microwave Anisotropy Probe) data. The image reveals 13.7 billion year old temperature fluctuations (shown as color differences) that correspond to the seeds that grew to become the galaxies.
Image: NASA and WMAP Science Team.