When a magnetic needle is brought closer to a current carrying conductor then the magnetic needle it gets deflected because the magnetic field of the current carrying conductor exerts a force on the magnetic needle, making it move from one direction to the other.
This force is proportional to the magnitude of current passing through the conductor.
it is because when current is passed through a current carrying conductor it produces a magnetic field around it and as the needle is magnetic so it gets deflected..