Why do objects have size? What is the reason objects, like coffee mugs, have size?
 A: There is a thing called energy, and it is conserved in the sense that if it leaves a region, you now have less of it in that region unless or until some more comes back into the region.  If you have some fundamental particles or composite objects they can have different energy based both on their state and how far apart they are from each other.  But if they ever arrange themselves in a way that has less energy and then they also give that excess energy away to something that isn't giving it back or at least not soon) such as radiating the energy into deep space, then they get stuck.  That's how hydrogen atoms $H$ get stuck to each other to form hydrogen molecules, $H_2$.  It's how carbon atoms form graphene, how organic molecules form, etcetera.
If the energy is lower when they are a certain distance apart, then they can get stuck that distance apart.  Like a spring that requires energy to compress it or the stretch it, if the energy is low enough it has no choice but to be at the distance that has the least energy.
Even the Pauli exclusion principle that people cite is just a special case of the same thing, that to be closer together given some states already, requires more energy so they stay at least a certain distance away.  Though it is a bit tricky because states can affect energy as well.
A: Well, I know some but not all of the answer numerically. But the main answer is "electromagnetic repulsion" and "Pauli exclusion principle." The nucleus is very, very small compared to the entire atom, so nuclear effects are not much of it. Off the top of my head, I've seen the calculation for how much of the pressure in an ordinary metal (which is basically a gas of electrons) is due to Fermi pressure due to Pauli exclusion. It's about half, iirc.
