And whenever the harmful spirit from God was upon Saul, David took the lyre and played it with his hand. So Saul was refreshed and was well, and the harmful spirit departed from him. (1 Samuel 16:23).
Since the Lord rejected Saul as king, He withdrew His Spirit; and Saul received an "evil spirit." The identity of this "evil" spirit has been disputed. Some believe that it was a demon. Others argue that it was a troubling spirit causing emotional disturbance (see Judg. 9:23). Some have suggested that the Lord permitted Satan to afflict Saul as punishment for his sin (see 2 Sam. 24:1 with 1 Chr. 21:1). What is clear is that this spirit was sent by the Lord (see 1 Kgs. 22:20–23) to show that Saul had been rejected. It caused Saul to experience bouts of rage and despondency. Christians do not have to fear that the Lord will remove His Spirit from them, since the Spirit is the believer's permanent possession (Rom. 8:9, 12–17; Eph. 1:13; 4:30). Holman concise Bible commentary (pp. 114–115).
I wanted to note in this passage that the evil spirit came and went. The situation was different in the Old Testament, in that the believers were not given the Spirit to indwell them. In the NT, we are. Once indwelling, we can never again be lost nor will the Spirit depart. However if we are is absent the Spirit, no amount of moralizing behavior will keep the evil spirits away. Eventually they enter in. Or eventually, they return.
You see this expressed in the New Testament verse of Matthew 12:43-45.
When the unclean spirit has gone out of a person, it passes through waterless places seeking rest, but finds none. Then it says, 'I will return to my house from which I came.' And when it comes, it finds the house empty, swept, and put in order. Then it goes and brings with it seven other spirits more evil than itself, and they enter and dwell there, and the last state of that person is worse than the first. So also will it be with this evil generation.
The house being swept is the person deciding to straighten up and fly right. "I'll be good!" they say, "I'll be moral." they promise. But without the Spirit's seal in us, the evil will return at some pouint, and the person will be even worse off.
Think of drug addicts who leave rehab only to do worse drugs in their relapse. The drunk who had yet to hit bottom but hits a new low on the way down. The dieter who puts on more weight after the diet than before. The flirt who acts on his flirtation this time. The unaided flesh can't be restrained.
As for Saul, Matthew Henry said:
How much better friends had they been to him if they had advised him, since the evil spirit was from the Lord, to give all diligence to make his peace with God by true repentance, to send for Samuel to pray with him and to intercede with God for him! then might he not only have had some present relief, but the good Spirit would have returned to him. But their project is to make him merry, and so cure him. Matthew Henry’s commentary on the whole BibleCuring your evil without the Spirit is hopeless. Saul did not seek Him, and attempted to use music as a symptom reliever. Play the lyre, sweep the house, try and try again. You can only cover up symptoms for so long. We all need the only cure, the final cure: Jesus and His Gospel.