What did David investigate?
Radak: If indeed she is Bas Sheva
How many Aveiros resulted from this?
Radak: He did not transgress Bi'ah with a married woman. Uriyah had given a Get to his wife on condition to take effect retroactively if he will be killed in war. This is why David arranged that he die in war!
Malbim citing Mahari; There were five Aveiros. (a) Bi'ah with a married woman. He holds that the verses are unlike Shabbos 56a, which says that Uriyah had divorced her. (b) He tried to get Uriyah to had Bi'ah with her so he will think that she is pregnant from him, and the child will be attributed to Uriyah. This can lead to siblings marrying! It says about this "u'Mal'ah ha'Aretz Zimah" (Vayikra 19:29)! (c) He caused Uriyah's death. It would have been better to detain him until after Bas Sheva gives birth, and they would give the baby to a wet-nurse, and no one would know. (d) Due to killing Uriyah via the sword of Amon, many Bnei Yisrael were killed. He could have killed him covertly! (e) He took Bas Sheva immediately to his own house as if his lust was still pursuing him. 1
Malbim: We cannot say that she was married. If so, she would be forbidden to David permanently 2 ! Why would he pray and fast for the baby to live? He was a Mamzer 3 ! How could his Teshuvah be accepted while he is still married to a forbidden wife? This is like immersing while holding a dead Sheretz! Hashem chose kings from Bas Sheva's seed, and "He called [Shlomo] Yedidyah", "and Hashem loved him" (12:24-25)! Rather, everyone who went to war at that time would write a Get to his wife, for often, men killed in war, their wives are Agunos (unable to remarry), for the dead are buried hastily and people do not recognize the faces to testify about them to permit the wives to remarry, especially when the enemy overpowers. Therefore, David's Beis Din enacted that they write Gitin to their wives, to divorce absolutely or on condition [that they not return at the end of the war]. She was "Bas Eli'am", the granddaughter of Achitofel, David's advisor. Surely he advised to make this enactment 4 . Surely he insisted that his granddaughter fulfill it, lest she be an Agunah! According to the opinion that the Get was on condition, surely it was retroactive (if he will not return at the end of the war, she is divorced from now). If not, he does not save her from concern for Agunah! 5 David intended to detain Uriyah with a mission at the end of the war, so he would not return with the others.
Malbim: Mahari holds that David sinned greatly, just through his Teshuvah his sin was removed. He received his punishment, and was purified. However, Chazal's Perush is proper. Refer to 11:3:2:3, 11:5:1:2, 11:9:1:1, 11:15:1:1, 11:27:1:2. .
Kesuvos 9a says that she was not forbidden to her husband, because it was Ones (coercion. Also the other answer there agrees to this. All permit a captive to her husband if he is a Yisrael!) Enticement of a minor is considered Ones (Yevamos 33b). Just like she was permitted to Uriyah, the Bi'ah did not forbid her to David (Rashba 9a)! (PF)
Tosfos (Chagigah 9a) - one who fathered a Mamzer, his shame persists as long as the Mamzer is in the world. Tzitz Eliezer (5:22:20, citing the Hafla'ah's father) - it is mercy for Hashem to kill the Mamzer!
What is the source that it was not enacted before David? Kesuvos 9b says that everyone who went to war in David's army wrote a Get to his wife. We find that David's family did so already in the days of Sha'ul (Shabbos 56a! However, perhaps it was enacted for all only later.) Ba'al ha'Turim (Bamidbar 32:11) says that Moshe enacted this! And what is the source that Achitofel was already David's advisor? He was only 33 when he died (Sanhedrin 69b) in Avshalom's rebellion, when Shlomo was seven years old (Rashi Melachim I, 3:7). Perhaps David enacted it when he first became king over all of Yisrael, when Achitofel was only five years old! (PF)
Why does it not suffice if the Get takes effect at the end of the war? Rashi (Kidushin 78b) implies that a Get cannot take effect at a time when the husband is Goses (close to death), but Tosfos (78b) brought strong proofs against this! (PF)