Magic is fundamentally controlled by magnetic fields
In order to answer this question you need to look at the properties of iron and find one thing about it that no other material available in your setting has or at least where it is a remarkable outlier. If you treat magic like radiation, then iron has a lower density than many other metal options like lead or bronze which would work better, so the radiation explanation does not work. If you are looking at magic like it is flowing electricity then iron as a semiconductor could neither be good for redirecting it as a copper alloy could nor at absorbing it out right like leather cloth. If you look at magic like flowing heat, iron has a pretty low specific heat so, you can't think of it like a thermal insulator. There is only really one property of iron that stands out in in how it interacts with any sort of know "magic like" forces, and that is its ferromagnetisms.
There are very few materials in nature that can meaningfully interact with a magnetic field. These are called ferromagnetic materials. In the pre-modern era, Iron was the only known ferromagnetic material, although cobalt, nickel, and certain rare earth metals may also make good magic resisters, they were not isolated as elements until the past few hundred years.
How you can explain it is that the world around us exists in some kind of magic scalar field that can only be manipulated by a physical being through magnetic fields. A lot of fantasy settings already have something like this: the weave, the aether, etc., but don't explain how it is manipulated. So for the sake of your setting, lets say wizards can create complex magnetic field patterns to manipulate the aether, and it is only through precise control of it that he can release its stored potential energy into a useable form.
The thing about iron is that it causes magnetic fields to change shapes; so, if a wizard is trying to make precise magnetic fields, any near by iron will change the shape of that field causing the spell to misfire.
Why does iron purity matter?
It has to due with crystalline structures. High purity carbon steels then to have crystalline structures that run in veins which are responsible for its ferromagnetic properties. However, many steels have higher concentrations of paramagnetic crystal structures like cementite and austenite that have much weaker magnetic properties. These special crystalline structures often come from "desirable contaminates" such as nickel, vanadium, molybdenum, chromium, magnesium, etc. So iron ores containing trace amounts of these metals were often recognized by blacksmiths for making higher quality steels, but they would have also been less magnetic.
In this regard you can sort of create a direct relationship between how good of a weapon/armor grade ore you have, and how good of spell resistance it will have.