The magnetic field of Earth and several other planets are produced by magnetic substances such as Iron and nickel present in the molten form in their core. With their motion, the domains of the magnetic material align in a single direction generating huge magnetic field.
The magnetic field helps protect from high speed solar particles and helps in navigation. Auroras are caused due to magnetic fields. Auroras can be seen of Earth, Saturn, Jupiter indicating that these planets have magnetic fields.
If an elements atomic mass and number are known you can also determine the number of protons and neutrons it has. You can also determine where it is on the periodic table. For example, if a element had a atomic mass of 10 then it would be higher up on the table then one with a mass of 20. Btw I do apex too.