If you read the chapters before, Saul rejected God so that was why God rejected him in the special priviledge of neing King. 1 Sam. 15:23
However, even though he did that, he repented before God. 1 Sam. 15:25
Even though God was upset with Saul, he offered a way for him to have peace if Saul now followed what God told him to do. 1 Sam. 16:16
Saul followed this counsel. 1 Sam. 16:17
Since Saul followed what God had told him to do, he now was refreshed and at peace. God's anger had departed from him. 1 Sam 16:23