A magnetometer is a device that measures magnetism—the direction, strength, or relative change of a magnetic field at a particular location. The measurement of the magnetization of a magnetic material (like a ferromagnet) is an example.
The micro:bit's built-in magnetometer MAG3110 chip is intended for use as compass to detect magnetic north. Like the compass app on your phone, this requires calibration and in my experience doesn't work very reliably. However, it is great for detecting the presence of a magnet!
The compass chip is more or less behind button B.
External Link to useful lesson