What EGW says:
Before the conclusion of the war with the Ammonites, David, leaving the conduct of the army to Joab, returned to Jerusalem. The Syrians had already submitted to Israel, and the complete overthrow of the Ammonites appeared certain. David was surrounded by the fruits of victory and the honors of his wise and able rule. It was now, while he was at ease and unguarded, that the tempter seized the opportunity to occupy his mind. The fact that God had taken David into so close connection with Himself and had manifested so great favor toward him, should have been to him the strongest of incentives to preserve his character unblemished. But when in ease and self-security he let go his hold upon God, David yielded to Satan and brought upon his soul the stain of guilt. {PP 718.1}