Because Magnetism is a form of Electrostatic force and holds a positive and negative charge. As we know even on the atomic level, opposite attracts opposite; proton to electron. Like repels like (electron to electron).
Same principle (in fact, the same force). Magnetism isn't a stand-alone force, it is a part of, or arguably the same as electromagnetism. So as electrons repel electrons, like poles of a magnet repel each other.
As for WHY these things repel each other, research is still being done and there is no definitive answer.
But then we enter the rabbit hole of "why"s. Each answer leads to a new "why" and no matter how many "why"s we can answer, we eventually get to one we can't... which ultimately leaves the original question unanswered.