The confusion in the verses I shall be examining lies in the multiple meanings of the Hebrew word ra’ (Strong’s word 7451). It’s usually translated as “evil” in English Bible translations (444 times in the KJV), but it has a range of meanings (beyond what we usually understand as wickedness, immoral, sinful, malevolent, hateful, etc.), according to the lexicons, including “disagreeable, unpleasant, giving pain, unhappiness, misery, sad, unhappy, trouble, grievous, affliction, calamity, distress, injury.”
This wide range accounts for the many times in the Bible that it is attributed to God. I contend that in these instances, the meaning is “righteous indignation” or “divine judgment”: which is perfectly just and warranted in cases of extreme rebellion and sin against God; failing to follow His commandments. Judgment is a quite unpleasant thing, and has the consequences of all the words listed above. But it’s not “moral evil” or wickedness.
Here are some of the many usages of “evil” in relation to God:
2 Samuel 17:14 (RSV) . . . so that the LORD might bring evil upon Ab’salom.
2 Kings 21:12 . . . Behold, I am bringing upon Jerusalem and Judah such evil that the ears of every one who hears of it will tingle. (cf. Jer 19:3)
2 Kings 22:16 Thus says the LORD, Behold, I will bring evil upon this place and upon its inhabitants, . . . (cf. 2 Chr 34:24)
Job 42:11 . . . all the evil that the LORD had brought upon him . . .
Jeremiah 11:11 Therefore, thus says the LORD, Behold, I am bringing evil upon them which they cannot escape; though they cry to me, I will not listen to them.
Jeremiah 18:11 . . . Thus says the LORD, Behold, I am shaping evil against you and devising a plan against you. . . .
Jeremiah 21:10 For I have set my face against this city for evil and not for good, says the LORD . . .
Jeremiah 32:42 . . . I have brought all this great evil upon this people . . .
Jeremiah 44:2 . . . You have seen all the evil that I brought upon Jerusalem and upon all the cities of Judah. . . .
Jeremiah 45:5 . . . I am bringing evil upon all flesh . . .
Jeremiah 49:37 . . . I will bring evil upon them . . .
Ezekiel 6:10 . . . I have not said in vain that I would do this evil to them.
Amos 3:6 . . . Does evil befall a city, unless the LORD has done it?
Micah 1:12 . . . evil has come down from the LORD to the gate of Jerusalem.
Micah 2:3 . . . Behold, against this family I am devising evil, . . .
Zechariah 8:14 . . . I purposed to do evil to you . . .
Apart from multiple meanings of the Hebrew ra’, it’s also a fundamental principle of biblical hermeneutics, that we interpret more difficult to understand Bible passages in light of those on the same general topic that are easier to understand. Here, then, are many passages which show clearly that the sense of “evil” when attributed to God means “righteous judgment” (which includes unpleasant things that are “evil” in this secondary sense):
Deuteronomy 7:15 And the LORD will take away from you all sickness; and none of the evil diseases of Egypt, which you knew, will he inflict upon you, but he will lay them upon all who hate you.
Deuteronomy 31:29 For I know that after my death you will surely act corruptly, and turn aside from the way which I have commanded you; and in the days to come evil will befall you, because you will do what is evil in the sight of the LORD, provoking him to anger through the work of your hands.
Joshua 23:15-16 But just as all the good things which the LORD your God promised concerning you have been fulfilled for you, so the LORD will bring upon you all the evil things, until he have destroyed you from off this good land which the LORD your God has given you,  if you transgress the covenant of the LORD your God, which he commanded you, and go and serve other gods and bow down to them. Then the anger of the LORD will be kindled against you, and you shall perish quickly from off the good land which he has given to you.
Judges 2:11, 15 And the people of Israel did what was evil in the sight of the LORD and served the Ba’als; . . .  Whenever they marched out, the hand of the LORD was against them for evil, as the LORD had warned, and as the LORD had sworn to them; . . .
1 Samuel 25:39 When David heard that Nabal was dead, he said, “Blessed be the LORD who has avenged the insult I received at the hand of Nabal, and has kept back his servant from evil; the LORD has returned the evil-doing of Nabal upon his own head.”
2 Samuel 12:9-12 Why have you despised the word of the LORD, to do what is evil in his sight? You [King David] have smitten Uri’ah the Hittite with the sword, and have taken his wife to be your wife, and have slain him with the sword of the Ammonites.  Now therefore the sword shall never depart from your house, because you have despised me, and have taken the wife of Uri’ah the Hittite to be your wife.’  Thus says the LORD, `Behold, I will raise up evil against you out of your own house; and I will take your wives before your eyes, and give them to your neighbor, and he shall lie with your wives in the sight of this sun.  For you did it secretly; but I will do this thing before all Israel, and before the sun.'”
1 Kings 2:44 The king also said to Shim’e-i, “You know in your own heart all the evil that you did to David my father; so the LORD will bring back your evil upon your own head.”
1 Kings 9:9 Then they will say, “Because they forsook the LORD their God who brought their fathers out of the land of Egypt, and laid hold on other gods, and worshiped them and served them; therefore the LORD has brought all this evil upon them.”
2 Kings 21:6 And he burned his son as an offering, and practiced soothsaying and augury, and dealt with mediums and with wizards. He did much evil in the sight of the LORD, provoking him to anger. (cf. 2 Chr 33:6)
Jeremiah 11:17 The LORD of hosts, who planted you, has pronounced evil against you, because of the evil which the house of Israel and the house of Judah have done, provoking me to anger by burning incense to Ba’al.
Jeremiah 16:10-13 “And when you tell this people all these words, and they say to you, `Why has the LORD pronounced all this great evil against us? What is our iniquity? What is the sin that we have committed against the LORD our God?’  then you shall say to them: `Because your fathers have forsaken me, says the LORD, and have gone after other gods and have served and worshiped them, and have forsaken me and have not kept my law,  and because you have done worse than your fathers, for behold, every one of you follows his stubborn evil will, refusing to listen to me;  therefore I will hurl you out of this land into a land which neither you nor your fathers have known, and there you shall serve other gods day and night, for I will show you no favor.’
Jeremiah 23:10-12 For the land is full of adulterers; because of the curse the land mourns, and the pastures of the wilderness are dried up. Their course is evil, and their might is not right.  “Both prophet and priest are ungodly; even in my house I have found their wickedness, says the LORD.  Therefore their way shall be to them like slippery paths in the darkness, into which they shall be driven and fall; for I will bring evil upon them in the year of their punishment, says the LORD.
Jeremiah 40:2-3 The captain of the guard took Jeremiah and said to him, “The LORD your God pronounced this evil against this place;  the LORD has brought it about, and has done as he said. Because you sinned against the LORD, and did not obey his voice, this thing has come upon you.”
Jeremiah 44:11, 22-23 “Therefore thus says the LORD of hosts, the God of Israel: Behold, I will set my face against you for evil, to cut off all Judah.” . . .  “The LORD could no longer bear your evil doings and the abominations which you committed; therefore your land has become a desolation and a waste and a curse, without inhabitant, as it is this day.  It is because you burned incense, and because you sinned against the LORD and did not obey the voice of the LORD or walk in his law and in his statutes and in his testimonies, that this evil has befallen you, as at this day.”
Moreover, God cannot sin:
1 John 3:3-9 And every one who thus hopes in him purifies himself as he is pure.  Every one who commits sin is guilty of lawlessness; sin is lawlessness.  You know that he appeared to take away sins, and in him there is no sin.  No one who abides in him sins; no one who sins has either seen him or known him.  Little children, let no one deceive you. He who does right is righteous, as he is righteous.  He who commits sin is of the devil; for the devil has sinned from the beginning. The reason the Son of God appeared was to destroy the works of the devil.  No one born of God commits sin; for God’s nature abides in him, and he cannot sin because he is born of God. (cf. 5:18)
James 1:13 Let no one say when he is tempted, “I am tempted by God”; for God cannot be tempted with evil and he himself tempts no one;
3 John 1:11 Beloved, do not imitate evil but imitate good. He who does good is of God; he who does evil has not seen God.
Photo credit: Nathan advises King David (1672), by Matthias Scheits (1630-1700) [public domain / Wikimedia Commons]
Summary: Confusion results from passages that seem to attribute evil to God. In fact, the Hebrew ra’ has multiple meanings, & these instances mean “righteous judgment.”