Israel captured the Philistine camp. In desperation, the Philistines attempted another raid. David could have looked at the situation from a human perspective.
People who have committed certain crimes, especially the more violent ones, have a higher rate of recidivism than others. The sad fact is that some prisoners are never able to escape their pattern of criminal behavior.
For scarcely for a righteous man will one die; yet perhaps for a good man someone would even dare to die. But God demonstrates His own love toward us, in that while we were still sinners, Christ died for us.