I didn't check this out but i this is what i believe to be the explaination. Basically magnets are metals which have a positive or negative charge on them (concerning the amount of electons) and positive is attracted to negative which creates the pull from a magnet to another substance whith an opposite charge and repulsion from substances with similar charges. I might be wrong and i could try to go deeper but i think that is why