What determines if magnetic spins align parallel or anti parallel in a material? As we all know, the magnetic field around a dipole looks like the following:

Notice how, directly above and below the magnet, the magnetic fields likes are parallel to the north-south axis. However, to the sides of the magnet, the magnetic field lines are anti parallel. If you've ever played with a magnet, you know that magnets, when placed end-to-end, like to align parallel, but when placed side by side like to align anti-parallel:

Now let's zoom into some magnetic material. It's made up of a bunch of elementary magnetic spins. Given the direction of the magnetic field lines, it's not clear which is more energetically favorabe: for all spins to point in the same direction, or for them to "flip" in a checkerboard pattern:

Is there a reason we always think about the first configuration and not the second? What property of a material decides whether the spins will all be aligned parallel or anti parallel?
 A: There are two important interactions in magnetic materials: the dipolar interaction and the exchange interaction. 
The dipolar interaction corresponds to the magnetic fields from the Maxwell equations. This field is dominant on the macroscopic scale. Therefore, if we look to the macroscopic bar magnets, they nicely follow the behavior of the magnetic field lines and thus will orient antiparallel when you place them next to each other. 
At the level of the atoms itself, the exchange interaction is dominant. This interaction describes the coupling between neighboring spins and thus determines the orientation of the atomic dipoles in the crystal. It is based on the Pauli-exclusion principle and thus has a quantum mechanical origin. There is a constant, the exchange constant, describing this interaction. When the exchange constant is positive, parallel alignment of the atomic dipoles is energetically more favorable, and, in this case, we talk about ferromagnets. Ferromagnets are more common (Fe, Ni, Co) and therefore we tend to think first to the ferromagnetic ordering. When the exchange constant is negative, antiparallel alignment of the atomic dipoles is favorable and here we talk about ferrimagnets or antiferromagnets. 
An example which illustrates the competition between the dipolar and exchange interaction in ferromagnets is the domain formation. The dipolar interaction wants to form as much as possible domains with opposite magnetic orientations. On the other hand, the exchange interaction (in a ferromagnet) prefers to form 1 big domain which has everywhere the same orientation. At a certain length scale, both interactions are comparable to each other which determines the size of the magnetic domains. Inside the domain (dimensions smaller than the domain size), the orientation is everywhere uniform and dominated by the exchange interaction. Over several domains (dimensions larger than the domain size), the interaction is determined by the dipolar interaction.
