Abimelech has not yet perfect light, but he has much more integrity than any of the other Philistines, and a recognition of the one universal God. ‘For I also withheld thee, says God, from sinning against me.
When we avoid committing some sin, perhaps because circumstances stood in the way, or perhaps because some warning made us afraid to proceed, we need to evaluate our conduct soberly. We cannot take credit for not doing what we wanted to do, just because our way was blocked. If God counts the will to act as commendable in the case of good deeds (2 Corinthians 8:12), he certainly counts it as evil in the case of sinful deeds. Alternatively, if a warning has held us back, then we can hardly say that we were motivated by a love of righteousness. Rather, we ought to thank God that he protected us from our sinful nature, and give him the credit for our abstaining, and not ourselves.