You can influence the direction of a compass needle using a permanent magnet.
Slide the magnet closer to observe the movement of the needle.
Without the presence of a magnet, the needle will align with Earth's magnetic field.