Uriah did sleep with her—she was, after all, his wife.
I presume you mean “What would have happened if Uriah had not refused to go home from the battlefront for a conjugal visit after King David had sex with her?”
Well, in theory—
- King David would not have felt compelled to hide her pregnancy by having Uriah killed in battle (by placing him at the front of the troops) , so Solomon would have been born and raised as Uriah’s son
- which meant that one of David’s other, far less wise sons would have ascended to the throne
- which would have resulted in a less powerful kingdom, and possibly no Temple being constructed (or a far less impressive one—without cedars from the Lebanon, or Egyptian-like architectural style and engineering, thanks to the experts accompanying Pharaoh’s daughter, whom Solomon married by virtue of his status)
On the bright side, however—
- Solomon’s foolish son Rehoboam would not have succeeded him, and brought about the breakup of the united kingdom into two (Israel and Judah) by needlessly antagonising the northern tribes and prompting them to secede
- David would not have been guilty of adultery and murder, so might have been permitted by God to build His temple.
In reality, however, probably little would have changed. David, being the red-blooded king that he was, would have likely committed these sins with someone else’s wife, or God would have found some other reason not to let him build the Temple, and have given great wisdom to whichever other son succeeded him, etc. So the names would have changed, but the overall chain of events would have been similar.
God moves in mysterious ways.