2 Samuel 11:1-3 tells us that she was the wife of Uriah, one of David's chosen elite corps of warriors. She was also the daughter of Eliam another of David's elite warriors. Eliam was the son of Ahithophel, David's chief counsellor. So Bathsheba was the granddaughter of Ahithophel. David and Ahithophel had been very close until his sin with Bathsheba. This brought open shame and disgrace on the family. This explains why Ahithophel turned on David when David's son Absalom rebelled against him. David's sin had terrible consequences which he could not escape and did not foresee. It caused him endless suffering and trouble for the rest of his life. The lesson for us is that, even though we might be forgiven of our sins, as David was, we must still bear the consequences of our bad behaviour in the subsequent outworking of our lives.
I hope you have found this helpful.