Magic plays a huge roll in lots of fantasy novels. Every writer has their own unique style of magic, with their own rules, effects, and causes, but there is one thing that all magic should have in common no matter who has written it.
“Magic should be a science. You can study it and learn it as if it were chemistry, but you may not be able to fully perceive everything there is to know without an affinity for the craft.”
This means definite laws that apply to the magic in question, even magic that may be considered ‘chaotic’ or ‘random’; this also means no pulling any explanations out of your ass to explain something that was done that seemed to have no reason behind it. You can create what you want, but understand the limits of your magic systems, and use those limits to your advantage regarding your characters knowledge or ignorance toward the craft.
As an example of this, in Taichiren’s Heart I have it so no one, not even gods, can cause harm or destruction while on a plane separate from the one they wish to cause damage on. There are three different planes that take a major role in the book, and all of them house different types of magic. As such, characters are forced to move around from plane to plane and cannot do anything nasty from inside their comfort zones.
Building off of this rule, your laws should have reasons. They don’t always have to have anything super specific or technical as you most likely won’t be explaining it in any great detail inside the book, but having an idea of what your laws actually mean can give you insight that you wouldn’t otherwise have.
To further explain my law, it has a ‘technical’ background. There are four main types of magic: Chaos, Order, Elemental, and Anti-magic. All of them exist in each plane, but in different forms, quantities, and for different reasons. There are also more reasons behind this and those stem further into the lore than anything, so it’s not important now.
Most other things about creating magic are up to you, the writer. What does it do? What does it look like? How do you use it, or protect yourself against it? Those questions, as well as many others, are some of the things you should be asking yourself when creating magic. Knowing all of these elements creates an effective magic system for your world, one in which you can write about with the knowledge of how it works, and reveal how it works slowly to your reader in a consistent way.