Anyone who has read any degree of sword and sorcery knows the reason, not purely practical,1 why sorcery does not replace swords in that genre's worlds.
Well, reasons. There is the aspect that it requires years of pouring over eldritch tomes in isolation. Consequently, sorcerers are rare. Partly because the temperament for that is rare, partly because the tomes are uncommon. It is possible for less study to lead to less powerful sorcerers -- Fritz Leiber gave the Gray Mouser a smattering of spells -- but that renders them less useful.
Still, the real reason is that sorcery is often evil. And evil beyond the moral objections of the notoriously less than rigorous swordsman heroes of the sword and sorcery genre
.
Not always. Leiber had them less evil, within the bounds of our heroes' tolerance. (For their magic at least; at any time, they were usefully evil enough to make them foes.)
Robert E. Howard, on the other hand, had one beneficent use of magic in all of Conan the Barbarian's adventures. That was the blessing of a deceased holy priest of a god of light on Conan's sword. Evil sorcerers are distinctly more numerous. Indeed, in one story, Conan allies himself with a sorcerer (against a common foe, also a sorcerer), and at the end reflects that although his ally had unquestionably saved his life, he never wanted to see him again.
So how is this sorcery all evil? And so evil that even allies who use it are evil?
Historically, the ancient Romans regarded such magic as powders of inheritance as evil because of their surreptitious nature. You sprinkled a powder in your uncle's soup, and as a consequence, you inherited. Your uncle was unable to defend himself. (And if the powder happened to be arsenic, they did not know enough chemistry for it not to be magia, working by hidden means.)
One can see how working a hidden rite, a kingdom away, so that your foe fell ill and died would bring particular horror.2 Perhaps it might work like medieval Iceland, where you had to proclaim that you had killed a man before you passed three houses, or you could not pay wereguild, but suffered outlawry. Cursing someone to his face might be less severely punished than secret curses.
Or perhaps not. One thing the genre tends to do even with magia is require that it use some kind of eye of newt that makes you evil to even buy. Sometimes, this stuff was portrayed as evil because it was used in sorcery, and therefore could not be the cause of its being evil. Sometimes it was just nasty by nature, such as poisonous plants, or ones that cause hallucinations. However, the writers did not stint themselves on describing the horrors that could be necessary. Grave-dust is merely the beginning, and grave-robbing is actually on the milder side. (Pulp can go for great excess quite easily.)
The classic is the tome of forbidden knowledge that uses human skin to bind it. Which is another side of it. To know things would be evil in itself -- except that the works tended to make vague, portentous declarations and not even tell you who forbade it. Like herbs that are evil because they are used in sorcery, this often carries nothing than the implication that it is used in sorcery and so evil.
Not so with the deeds that are required to perform it. This emerges from the eye-of-newt issue with no clear boundary. If you must steal something from your victim to curse him, is that eye of newt or working the curse itself? Who cares?
What matters is that you did something evil in pursuit of your sorcery. Theft is rare, perhaps because it is so low in the scale of wickedness. Assault to obtain blood is only a bit higher. Murders are commonplace and ugly.
Not to mention -- the curse? That's the usual sort of thing for sorcerers to do. Whether evil deeds are the only thing that sorcerers can do, it is frequently the only thing they did do. Painful and lingering deaths, malicious transformations, epidemics, famine -- enough of those, and everyone will agree you are evil.
Even the classic love potion has ugly implications, and many of the traditional uses for magic don't appear. Characters don't look for lost things with magic, not even to search for treasure. Only worse deeds are involved.
(If it's possible to use it for good purposes, those sorcerers still need to walk warily to demonstrate their good faith. All the more in that the knowledge could no doubt go either way.)
Finally, many sorcerers trafficked with evil spirits. That is enough to stain it. The spirits would work for evil deeds -- why would they do good? -- tell you things you were better off not knowing, and describe ways to work with eye of newt that you were better off not knowing existing. Ancient Romans and Greeks not only prosecuted this, they prosecuted this as impiety.
There are any number of ways by which the swords could be required in sword and sorcery if only because the sorcery remains firmly ensconced in the villain's hands, with no overflow.
For purely practical see this
The Sword And The Sorcery
I once read someone grumbling about why on earth would you have swordsmen in a world where you had sorcery.
And particularly inspire the desire for defenses against it.
Defense From Magic
In a world where powerful wizards -- high-level, if you prefer -- can blast armies to smoking ashes with a single fireball spell, why don't wizards rule the world?
I have read a few books that went into detail on the medieval and early modern grimoires like A.E. Waite's 'Book of Ceremonial Magic', which is a fine resource by the by (it's history, not a how-to). I recall him mentioning that many of the grimoires stated that conjuring demons wasn't actually evil if you did it for 'the right reasons'. After all, didn't Jesus himself say that 'In my name you will command demons'? Waite himself was unconvinced as i recall.
Magic is a metaphor for madness. Wizards are nutters, people who've gone too far into the chaos for too long and returned as madmen.
As far as R. E. Howard's Conan stories, in The Hand of Nergal, Conan had the enchanted amulet The Heart of Tamusz (implying a goodly sorcerer made it or it was a gift from the Gods). Also, there was a sorcerer on Conan's side in that story who used a scrying crystal to track events. While the scrying was not directly to Conan's benefit, it was an indirect aid.