David had relations with Bathsheba. Bathsheba got pregnant. David then told Uriah to return to Bathsheba. Uriah refused and latter David technically lawfully kill Uriah. See II Samuel 11.
A rabbi here http://torahideals.com/essays-and-imaginings/david-and-bathsheba/ then argues that David didn't sin at all.
The idea is that Uriah had a retroactive divorce against Bathsheba. So, when Uriah died, the retroactive divorce was in effect. Hence, technically, Bathsheba was nobody's wife, and hence being with her was not a sin.
The website assumes that having relations with single woman is not a sin. Notice that this is a pretty conservative rabbi. So for now, let's just agree with the website and "assume" that sex outside marriage is not a sin.
Now that we have that assumption, another problem shows up.
So David is technically not doing adultery thanks to the retroactive divorce. Uriah is dead, anyway. Killing Uriah is also not technically murder due to another technicality. Everything is up up.
Then, why did David ask Uriah to come back to his wife?
If Uriah goes back to his wife, then the retroactive divorce won't hold. That means Bathsheba was still "technically" Uriah's wife. That means David would have committed adultery.
One of the comments points this out
While the ‘get’ may be effective retroactively, David was not in that “space” yet. Uriah had not been killed or missing in battle yet, so the “retroactive” stuff wasn’t operative? How could it be? If Uriah had returned alive from the battle, the ‘get’ would not have been effective, no? He would still have been married to Mrs. Uriah.
It seems that the pious thing to do, technically, is to just technically kill Uriah and continue having relations with Bathsheba. Which is what the pious David did anyway eventually.
But here, David is tempted to sin by asking Uriah to go back to Bathsheba. Had David succeeded, that would technically made his act post facto technical adultery.
Why would pious David do that? Bad lawyer?
Also - if Uriah did return to his wife, did David expect Uriah to know that his wife was already pregnant? Did David plan to man up and pay child support or did he expect Uriah to unknowingly raise his children?