(a) A magnetic dipole placed in an external magnetic field on acted upon by a torque which tends to align the dipole in the direction of the field. Therefore, work must be done to charge the orientation of the dipole against the torque. This work is stored as potential energy $(U)$ in the dipole, given by
$U = \mathbf{M.B}$
$U = - MB\cos\theta$
Where M is magnetic moment, $B$ the magnetic field and $\theta$ the angle between them.
Thus, a magnetic dipole has minimum potential energy when
M and B are parallel $(\theta = 0)$that is,
$U_{\min\ } = - pE$