Different translations describe the spirit in different ways:
- NIV, KJV, NASB, ISV - Evil
- ESV - Harmful
- NLT - Tormenting
- YLT - Spirit of Sadness
However all these translations agree that this Spirit was sent from the Lord. So to stay with your question, how could a loving God send an evil spirit to torment?
He could for the very same reasons he sent a worldwide flood: it was His divine way to deal with the sin of that time, of that moment. Saul was rebelling and this was his de facto punishment.
Dave Miller, Apologetics Press:
As Keil and Delitzsch maintained: “This demon is called ‘an evil spirit (coming) from Jehovah,’ because Jehovah had sent it as a punishment” (1976, 2:170). John W. Haley added: “And he has a punitive purpose in granting this permission. He uses evil to chastise evil” (1977, p. 142). Of course, the reader needs to be aware of the fact that the term for “evil” is a broad term that need not refer to spiritual wickedness. In fact, it often refers to physical harm or painful hardship (e.g., Genesis 19:19; 2 Samuel 17:14). source
Habakkuk had this very same question for God when it was clear that God was allowing the wicked nation of Babylon to punish Judah. God responded with this:
Habakkuk 1:5 ESV Look among the nations, and see; wonder and be astounded. For I am doing a work in your days that you would not believe if told.
...and then gave Habakkuk his rebuke for Babylon:
Habakkuk 2:8 ESV Because you have plundered many nations, all the remnant of the peoples shall plunder you, for the blood of man and violence to the earth, to cities and all who dwell in them.
Basically, God's great plans extend beyond the painful moment. God had a plan to rescue Judah from Babylon/Persia just like God had a plan for Saul in sending the evil spirit, even though neither made sense at the time. If you continue reading the chapter in 2 Samuel you'll see that it is through this evil spirit that Saul has his first encounter with his royal successor, David.