The first thing you need boys and girls, are some quantum fluctuations in the fabric of spacetime. These will be the seeds for your galaxy. There is still quite a bit of debate about how we put the quantum flucutations into the picture in the first place and the truth is we don't know. Could be M-theory(what string theory is now called), could be something else.

After imprinting the universe with quantum fluctuations we need to make the fluctuations bigger. We need to make them galaxy sized. In order to do this we use Inflation and blow up all length scales exponentially. The inital seeds ought to have had a flat power spectrum ensuring that when we increase the size of the fluctuations there are fluctuations on all scales.

The initial seeds can be not exactly flat, but most people agree that they ought to be pretty flat. A non flat power spectrum is called a tilted spectrum and I'll mention below why one might want such a thing.

Now in the midst of all of this inflation matter gets dumped into the universe. Again the details are at moment more of a sketch than anything else.

Now we have large fluctuations in spacetime, we have matter, all we need next is gravity. Matter comes with gravity included (in some pictures at anyrate). The gravity starts the matter coalescing. This begins along the inital fluctuations. As matter falls into the wells in the fluctuations the potential wells get deeper and more matter falls in. Pretty soon (Oh say a few billion years after we inflated everything) most of the matter (think greater than 90 percent) has fallen into dense clumps that are woven throughout the universe.

At a certain point pretty early on in the process the collapse of matter into lumps become non linear and very complicated to understand. Up to that point the physics makes a prediction about how matter should be distributed through the universe when we count galaxies.

Probably after the collapse becomes non linear star formation kicks in and our big lumps of matter become visable, they are now optically recognisable as galaxies.

Here is the clever bit, we can now see the things, we can measure their spatial density and their clustering properties. On the largest scales, in principle, the only physics that has gone in is the intial power spectrum. By measuring the clustering properties of the galaxies we can read off the power spectrum and get some insights into physics at the smallest scales imaginable (all by looking at the largest scales, cool eh!). Some observers believe that there is not enough formation of galaxies observed at the low mass end to agree with an intial flat power spectrum, a tilted power spectrum can let you shift the structure formation towards one end of the mass scale or the other depending on the tilt. IMHO there is not enough evidence to call it yet and more importantly not enough understanding of the theory of non-linear structure formation.