1) Electrons fill atomic orbitals according to specific rules in order to minimize the atom's energy. The order is 1s, 2s, 2p, 3s, 3p, 4s, etc. up to the noble gases.
2) The Pauli Exclusion Principle states that no two electrons in an atom can have the same set of four quantum numbers. This means that most orbitals can hold two electrons at most with opposing spins.
3) Hund's Rule states that electrons will occupy all degenerate orbitals before pairing up, resulting in atoms having as many unpaired electrons as possible in their ground states.