Exodus 22:18 famously says:
Thou shalt not suffer a witch to live.
Without a doubt, this was the basis of the belief that witches should be put to death. The Calvinist Bible commentator Matthew Henry says about this verse ("our law" refers to the law of Britain and Wales):
Witchcraft not only gives that honour to the devil which is due to God
alone, but bids defiance to the divine Providence, wages war with
God's government, and puts his work into the devil's hand, expecting
him to do good and evil, and so making him indeed the god of this
world; justly therefore was it punished with death, especially among a
people that were blessed with a divine revelation, and cared for by
divine Providence above any people under the sun. By our law,
consulting, covenanting with, invocating, or employing, any evil
spirit, to any intent whatsoever, and exercising any enchantment,
charm, or sorcery, whereby hurt shall be done to any person
whatsoever, is made felony, without benefit of clergy; also pretending
to tell where goods lost or stolen may be found, or the like, is an
iniquity punishable by the judge, and the second offence with death.
The justice of our law herein is supported by the law of God recorded
here.
Matthew Henry wrote this decades after the Salem witch trials. But his argumentation is much the same as that of the English Puritan William Perkins, who I'll get to later, who died well before the trials began.
According to Puritan doctrine, as codified in the Westminster Confession of Faith, the law of Moses can be divided into three categories: the moral, civil, and ceremonial. According to the confession, the moral law is still binding on all Christians, but the ceremonial law, which was a shadow of Christ who was to come, is done away with. But we have a more complicated relationship with the civil/judicial law (from chapter 19):
To them [Israel] also, as a body politic, He gave sundry judicial
laws, which expired together with the State of that people; not
obliging under any now, further than the general equity thereof may
require. [Exo 21-22; Gen 49:10; 1Pe 2:13; Mat 5:17; 1Co 9:8]
So did the general equity of the people require witches to be executed? That's the question of the day.
William Perkins, a "foremost" Puritan, gave three reasons for executing witches in his Discourse of the Damned Art of Witchcraft:
First, this Law of Moses flatly enjoineth all men, in all ages,
without limitation of circumstances, not to suffer the Witch to live;
and hereupon I gather, that it must stand the same both now and
forever to the world's end.
Perkins then mentions the objection that this was a law of the Old Covenant, and replies:
Those Judicial Laws, whose penalty is death, because they have in them
a perpetual equity, and do serve to maintain some moral precept, are
perpetual.
He adds that laws "that hath in it the equity of the Law of nature" are also perpetual, and says that all states execute traitors to the king, so how much more should one who is a traitor to the king of kings be executed.
He goes on:
The second reason for the proof of the point in hand is this:
According to Moses' law, every Idolater was to be stoned to death. ...
Peter did not upon his denial betake himself to the Devil, but turned
unto Christ again, which he testified by his hearty and speedy
repentance: but witches deny God, betake themselves to the devil, of
their own accord, as is manifest even by their own confessions, at
their arraignments.
...
The third reason. Every seducer in the Church, whose practise was to
draw men from the true God to the worship of Idols, though it were a
mans owne son or daughter, wife or friend, by the peremptory decree
and commandment of God, was at no hand to be spared or pitied, but the
hand of the witness first, and then the hands of all the people must
be upon him, to kill him, Deut. 13. 6. 9. If this be so, no Witches
convicted ought to escape the sword of the Magistrate; for they are
the most notorious seducers of all others.
Perkins examines several objections to this line of thinking:
the hurt that is done, comes not from the Witch, but from the devil;
he deserves the blame because it is his work
Perkins replies to this objection with an analogy: the devil and witches are like robbers in a conspiracy. The devil is the head of the conspiracy and the chief actor, but the witches are still guilty.
Another objection:
Witches convicted either repent, or repent not: If they repent, then
God pardoneth their sin, why should not the Magistrate as well save
their bodies, and let them live, as God doth their soules. If they do
not repent, then it is a dangerous thing for the Magistrate to put
them to death: for by this means he kills the body, and casts the soul
to hell.
To this he replies, "the Magistrate must execute justice upon malefactors lawfully convicted, whether they repent or not," but he adds that if they repent it is "possible for them to be saved by God's mercy."
Perkins concludes by saying, among other things:
By the laws of England the thief is executed for stealing, and we
thinke it just and profitable; but it were a thousand times better for
the land, if all witches, but especially the blessing Witch might
suffer death. For the thief by his stealing, and the hurtful
Enchanter by charming, bring hinderance and hurt to the bodies and
goods of men; but these are the right hand of the Devil, by which he
taketh and destroyeth the souls of men.
For some reason, dear reader, I have a feeling you're not convinced by Matthew Henry or William Perkins. Yes, their argumentation does not seem sound to our modern ears. With the benefit of hindsight we know what tragic and grave errors these men made.
However, C. S. Lewis believed that the main reason we're so repulsed by witch executions is simply that we don't believe in witches anymore, and that, if we did, we wouldn't see a problem with their execution so long as adequate evidence was presented (Mere Christianity, Chapter 2):
One man said to me, "Three hundred years ago people in England were
putting witches to death. Was that what you call the Rule of Human
Nature or Right Conduct?" But surely the reason we do not execute
witches is that we do not believe there are such things. If we did –
if we really thought that there were people going about who had sold
themselves to the devil and received supernatural powers from him in
return and were using these powers to kill their neighbours or drive
them mad or bring bad weather, surely we would all agree that if
anyone deserved the death penalty, then these filthy quislings did.
There is no difference of moral principle here: the difference is
simply about matter of fact. It may be a great advance in knowledge
not to believe in witches: there is no moral advance in not executing
them when you do not think they are there. You would not call a man
humane for ceasing to set mousetraps if he did so because he believed
there were no mice in the house.