How do rocks store information about Earth's magnetic field?

The field direction is stored in the magnetization direction of ferromagnetic minerals in the bedrock when it cools down. Those minerals are typically iron oxides like magnetite Fe$_3$O$_4$ etc or iron sulphides like pyrrhotite Fe$_7$S$_8$, with admixtures of other elements.

Such minerals are often not really hard ferromagnets, but their coercive field is large enough that the magnetization does not follow a switch of the Earth's magnetic poles.

One can do similar things with pottery or with the magnetization near hearths in archeological digs. This can give an indication of the direction and strength of the magnetic field in recent times, at many sites.

The critical temperature is the Curie temperature of the material. Above that, there is no ferromagnetic magnetization, the material is in a paramagnetic state, where the spin moments do not have long-range order. When the material cools below the Curie temperature, magnetic order will appear with a magnetization direction dependent on the external field.