David messed up big time. His first mistake was to not be where he was supposed to be. He probably should have been on the battlefield but he chose to stay home. His second mistake was inquiring about Bathsheba. At that step, God tried to warn him through an unnamed servant. "And one said, 'Is this not Bathsheba, the daughter of Eliam, the wife of Uriah the Hittite?"
This person told David who she was, how her grandfather was an advisor to him and how her husband was one of his mighty men (http://crimsonthread.org/articles/Bathsheba), but David didn't care. He wanted her for himself.
His third mistake was not admit his wrong when she came to him. Instead he plotted on how to hide his sin. He sent for her husband.
I wonder what Bathsheba thought? Maybe she thought he was going to speak to her husband, admit the sin and try to make restitution. If David had been courageous enough to be vulnerable, something good could have come out of this. Instead, he was a coward and committed more sin and tried to get Uriah to act selfishly.
Even people who adore God can fall into great sin if we don't stay transparent.
So, David had Uriah killed.
And he reaped the results of his sins for the rest of his life (as did all of Israel).
It messed up his family. It messed up his kingdom.
What if he had chosen differently?
We'll never know.
If we realize we've sinned, it is best to at that moment, confess it, turn from it and make restitution for any we hurt in the process. The longer we wait the harder it will be to do the right thing (and very likely the more damage we will do).