The correct explanation for why the compass needle moved when the wire was connected to the battery is:
The current-carrying wire created a magnetic field.
When an electric current flows through a wire, it generates a magnetic field around it. This magnetic field interacts with the compass needle, which is itself a small magnet. As a result, the compass needle aligns itself with the magnetic field generated by the current in the wire, causing it to move. This phenomenon is a fundamental principle of electromagnetism.