The concept of magic is mythological, ancient, and has developed up into our contemporary times. No one really has an answer to the exact nature of magic or where the idea began in history. It may simply be an answer to explain what some people did not understand long ago. Human beings are quite creative with expansive imaginations, so someone, somewhere, came up with the idea at some point in the ancient past. Their motivations, reasons, and purposes are unknown, lost in time.
Historically, the use of the concept has taken on many iterations in human society for better or worse. In some cases to invoke fear in enemies (important to some in a brutal, dangerous world), to deceive (one reason for religious objections), gain prosperity (cha-ching!), to feel protected from the unknown/unseen, gain favor (or love!), or as a way for some people to feel empowered (I’m strong!). Others have a desire to feel important by gaining some secret knowledge or ability that others do not have. One example today driven by the prosperity motivation are illusionists. They use illusion and slight of hand to entertain a paying audience.
In the end, we know that magic is simply not real. Nope, not real at all.