Well, I’d direct you over to @joannalannister who would explain that Tywin was very much a sentimentalist when it came to his wife.
On a more practical level, Tywin had dozens of nephews and nieces and cousins, so House Lannister wasn’t hurting for heirs.