In all compasses, there is a magnet that feels the pull of the strong magnetic force of the North Pole. The earth is filled with an iron core which also creates a magnetic pull; thus, the iron core is like a huge magnetic bar, stretching from the South to the North Pole. The iron in the middle of the earth is extremely hot, so the iron turns into a solid. With the heat from the core, and the earth rotating, the iron, of course, rotates with the earth. As the liquid iron is moving around and around, this liquid iron forms into the bar magnet around the axis of the earth. Hence the the North Pole has this magnetic force.
Interestingly, there is also a force known as the Magnetic North, located in Canada, and this is actually to what compasses point. (the second "North Pole.") This spot, discovered in 1831, moves about 10 miles northwest every year, so it has moved many miles since its discovery.
however, the compasses DON'T always point north! example 1. if you stand next to a metal building the iron in the building will deflect the compass. 2. if you are backpacking and carrying something iron; the compass will be deflected. 3. if there is an iron deposit nearby; the compass will be deflected.
one method of finding ore is to use a magnetometer which measures the field and direction of the spot you are on. by traveling with it and keeping a record, you can mark the deflection changes. One friend found a railroad spike driven into a tree using one.