A compass needle is a small magnet that is free to turn, so it lines up with any magnetic field it is in. When there are no other magnets nearby, the needle lines up with the Earth's magnetic field and its north-seeking end points towards the north. The Earth behaves as if it has a huge bar magnet inside it. The magnetic poles are not in the same place as the geographic poles.
A dipping compass has a needle that can turn up and down as well as round. At the equator the needle lies flat, parallel to the ground. Moving towards a magnetic pole, the needle tilts further and further down, until at the magnetic pole it points straight down. This pattern of angles is exactly what you would find around a bar magnet, so the Earth's field has the same shape as the field of a bar magnet.
This is evidence that the core of the Earth must be magnetic. The core is made mostly of iron and nickel, which are magnetic metals, and this fits the evidence.