When the switch is closed, current starts flowing in the coil. By applying Fleming’s Left-Hand Rule, the force on one side of the coil moves up, while the force on the opposite side moves down. This creates a couple (a pair of equal and opposite forces) that causes the coil to rotate.
The direction of rotation depends on the polarity of the battery and the direction of the magnetic field. If the current is reversed, the direction of rotation will also reverse.