When current is made to flow through the wire, a magnetic field is produced around it. When the compass needle is placed below the wire, it experiences a torque due to this magnetic field. So it deflects to align itself in the direction of magnetic field.