Magic was a system of understanding the world before even the advent of spiritism, where a life - or a soul - was afforded to all things; animals and trees for example.
Then after spiritism came religion, where instead of using sorcery (different from magic) to conjure and influence the world, a high, independent, status was afforded to the gods for which you had to curry favour by prayer or sacrifice.
But first, was magic. What Freud calls 'omnipotence of thought' - the thought is as good as the deed. The psychic (interior) world is a mirror of the real (exterior) world and so therefore what you think or do (symbollically) simultaneously happens in the world. The magician was in sympathy with the world and vice versa.
They are fundamentally three different stages of perception through human history and its not because they are in history that I am interested in them, but because one was a foundation for the other and their manifestations still persist in the human mind.
Freud [Totem & Taboo] draws the analogy between early man (the primitive or savage in his words) and early life, childhood. He compares the growing up of humankind to that of the life of an individual. You can infer that makes early man childish (though I'm not neccessarily accusing Freud of suggesting that) and modern man as grown up.
But we are no more grown up that early man with his different outlook on the world. In fact you might argue that we are less grown up.
Each time a new world-view came about, it displaced the other. We can see that with changing mythologies, where one symbol replaces another. The totem symbol becomes gods and then God. But they are all the same, just expressed differently, they are our desires. These different expressions, however, reflect very different views on how we see ourselves in the world.