Ferromagnetism occurs when it is energetically favorable that the spins of the electrons in the material are ordered in one direction and there's an "energy gap" between this magnetized state and the unmagnetized state. The microscopic reason that this happens in some few materials is quantum-mechanical. On the macroscopic level it's sufficient to know that this energy argument holds. This, however implies that to change the magnetization you need to do work to redirect the spins, and the change of energy is given by ##\int \mathrm{d} H B##, i.e., the area under the hysteresis curve.