This is about ritual purity, not moral purity.
According to Leviticus 15:19-30, a woman is unclean during her monthly period, until 7 days have passed. It may be as simple as she had been on her period, but the time had passed so that David would not be unclean if he had relations with her.
Leviticus 15:1924,28-30 NIV
19 “‘When a woman has her regular flow of blood, the impurity of her
monthly period will last seven days, and anyone who touches her will
be unclean till evening.
20 “‘Anything she lies on during her period will be unclean, and
anything she sits on will be unclean. 21 Anyone who touches her bed
will be unclean; they must wash their clothes and bathe with water,
and they will be unclean till evening. 22 Anyone who touches anything
she sits on will be unclean; they must wash their clothes and bathe
with water, and they will be unclean till evening. 23 Whether it is
the bed or anything she was sitting on, when anyone touches it, they
will be unclean till evening.
24 “‘If a man has sexual relations with her and her monthly flow
touches him, he will be unclean for seven days; any bed he lies on
will be unclean.
28 “‘When she is cleansed from her discharge, she must count off seven
days, and after that she will be ceremonially clean. 29 On the eighth
day she must take two doves or two young pigeons and bring them to the
priest at the entrance to the tent of meeting. 30 The priest is to
sacrifice one for a sin offering and the other for a burnt offering.
In this way he will make atonement for her before the Lord for the
uncleanness of her discharge.
There may even be some implied irony here, if indeed he was avoiding ceremonial impurity in order to commit adultery.
It may also be implied that David avoided this so it would not curtail ongoing relations with his wives and concubines, since any other bed he was in would be unclean for seven days. This is my own speculation, of course.
It also makes clear that Bathsheba is not already pregnant, as a woman does not have her period when she is pregnant. Therefore, she is pregnant by David, not her husband, Uriah.