It happened, when the [evil] spirit from God was on Saul, that David took the harp, and played with his hand: so Saul was refreshed, and was well, and the evil spirit departed from him.
God was elevating David from the ranks of a shepherd of sheep (1 Samuel 16:11) to become the shepherd of His people, and David’s musical ability (1 Samuel 16:18) enabled him to lead the Israelites in the worship of Yahweh later.