Earlier in the universe, things were very hot and very uniform. We can
directly see light left over from that era in the Cosmic Microwave
Background.
The galaxies and stars formed by gradual clumping of material
around spots that by accident had a little more than their share of
stuff. (We can even see those tiny irregularities in the Cosmic
Microwave Background.) Gravity would pull other matter into those
spots, and friction allowed that matter to dump its energy and stick in
clumps.
Tracing things back even earlier means tracking the cosmology back
toward a Big Bang, in which all the parts of the universe which we now
see were compressed down to a point, or whatever is the closest thing
to a point in nature. We don't really understand anything about nature
on that tiny a scale yet.
In between the time scale which we don't understand and the time
scale of the microwave background, there were a series of very dramatic
events, but they form too long a story for one of our little answers.
There are some great articles in the Scientific American magazine (your
library probably has a large stack of them) on the history of the
aftermath of the Big Bang, and we recommend you look at those. If you
have further questions, please come back.
Mike W.
(published on 10/22/2007)