A current carrying coil behaves as a magnetic dipole. Therefore, in a uniform magnetic field coil will get aligned such that the dipole moment of the coil is parallel to the magnetic field. And we know that dipole moment of a coil is perpendicular to its plane. Therefore, coil will align itself such that its plane is perpendicular the direction of magnetic field.