In the first human conceptions of the world, nobody thought that any part of reality obeyed fixed natural laws. That is the nature of magic, the basis of primitive religions and world views. According to magical thinking, there is no law, no order; there are simply the whims of demons, demigods and unknown supernatural creatures whose actions have unpredictable and arbitrary effects on human beings.
There are a few laws of traditional magic. Human magicians might learn some techniques to perform works of magic (make spells, cast charms, heal, curse, etc) but no part of magic explains the mechanisms of how things work. Some forms of magic contain some axioms that are derived from an early and primitive form of logic or guesswork. The idea that macrocosm follows microcosm, meaning that the action one takes on a small scale can be reflected on a larger scale, is one such magical axiom. This is the basis of voodoo dolls.
The idea that the world is not simply a random series of arbitrary events caused by malicious or benevolent beings – or even without actual causation – is one shared by modern religions and science. The concept that everything happens according to discernable and discoverable laws actually started with modern religion, specifically with the monotheistic Abrahamic religions. Organized religion went on the war path against magic in a big way when Christianity and Islam spread throughout the world. The old demigods, the controllers of local streams, the moon, the weather, good and bad luck and so on, were banished in favor of a single God who created and then ruled the world according to His own unbreakable law.
When the scientific method began to be used by the early natural philosophers, their work was generally greeted with enthusiasm by the Church. Science was seen as the way to understand God’s natural laws. The divisions between science and faith that plague us today began much more recently and will be the subject of many other posts. But the first thing to understand is that science and religion are actually united against the capricious and unknowable worldview of magic.
The struggle against magical thinking is far from over. Astrology, crystals, pyramids, and other new age fads are only the tip of the magical iceberg that still infects many modern minds. Magic makes a strong showing in certain conspiracy theories that posit some mysterious, powerful (usually human, or sometimes Alien) groups that can control our minds, spread poisons, and so on.
Many atheists confuse religion and magic. They see magic in the miracles of the Bible, and even in the belief in God. This is an understandable error, and there could be a component of magic in religious belief and practices. But the same is true for science. After all, in mathematics we have irrational and imaginary numbers; in physic we have photons that seem to magically decide whether to be a wave or a particle once we look at them.
The key difference between magic on the one hand and science and religion on the other is that the former acknowledges no over-arching rule of law, while the latter two do. This commonality could be the basis for better mutual understanding.