My friend Pete Hague recently answered a question on his blog regarding whether you can touch dark matter. He gave a good, basic explanation using coulomb’s law and then directed people towards me for a fuller solution. So here it is.
As Pete quite rightly explained, the coulomb repulsion of electrons stops atoms from getting too close to each other thus giving the feeling of solidness to objects, but before you even consider bringing atoms together you run into a problem bringing their constituents together.
Quantisation
If you want to build hydrogen you need a proton and an electron. The negative electron orbits the positive proton and you have an atom. The problem is that everyday experience tells us that the positivenegative attraction would just pull them together until they were touching, leaving no stable structure to the universe. But the experience we have turn out to be just a large scale effect, and at the quantum level things work differently.
In the quantum mechanics of atoms the energies that the bound electrons can have can only take certain values in an analogous way to the strings in a piano only being able to play certain notes. Theses energies in a basic atom are given roughly by
where Z is the charge of the nucleus of the atom and n ranges from 1 to infinity and at a basic level counts the different energy levels. Each of these energies will have a corresponding orbital radius given by
So if we take our proton and add an electron to make hydrogen the electron will have to have an energy of 13.6 eV and orbit at a radius of 52.9 picometers. It can’t get any closer as there are no lower energy levels or radii for it to be at.
This gives us our first step to structure, one hydrogen atom has to have a volume of around 620000 cubic picometers, you can’t squash it any smaller. But what about other elements that have more than one electron? What about carbon? For carbon we have Z=6 and 6 electrons, so do they all have energies of 489 eV and orbit at 8.8 picometers? The answer is no.
Exclusion
The thing that gives atoms and all matter additional structure is the Pauli Exclusion Principle. If we have a system of two particles, A and B, in two possible states, 1 and 2, then the description of the system will be of the form
We now need to outline two important features of particles;
 All particles of the same type are indistinguishable from each other.
 Matter particles are antisymmetric.
From point 1 we don’t know which particle in is which state so the proper description of the system should take into account both possible combinations, this is done in the following way:
From point 2 we have to pick the minus condition. If we were dealing with force particles it would be the plus but for matter the antisymmetry means we have a minus sign.
So now we have an expression for a system containing two identical particles. What happens if we try to put them in the same state, say ϕ_{1}?
Therefore you cannot have two identical particles in the same state.
So if we go back to our case of carbon, all 6 electrons are not allowed to just orbit at the same distance with the same energy. We can add the fist electron to the 489eV/8.8pm state, but to add the second electron something will have to be different. In this case it will be spin. You may or may not know that electrons have a quantum property called spin, it can either be up or down and provides a way to get two electron at the same energy and radius as one will be spinning up and the other down meaning the states will be slightly different. As soon as you’ve got the first two electron on that state it is then filled and so you move on to n=2, with a new energy and radius.
At this point things get a lot more complicated and you get more and more ways of getting electrons into the same n level with slightly different states. You have to include things like orbital angular momentum, magnetic effects and Hund’s rules but electron by electron you can build up the entire periodic table which will have the general trend of atoms getting bigger ^{[1]}.
So through a combination of electrons only being allowed at certain radii with certain energies, and that no two electrons can occupy the same state you end up building bigger and bigger structures that cannot just collapse in on themselves. Then combine this with the electromagnetic explanation that Pete gave and you have the mechanism behind almost all the structure in the universe.

Effects from the nucleus and other electrons will cause deviations from the increasing trend as shown here.↩