Tyrion is also the last legitimate heir of the Lannister line. Once Cersi dies, he becomes next in line for king. He will also need Sansa to provide him with heirs, long term.
I am guessing that the peaceful replacement for Cersei upon her death is Tyrion as hand of the king and Sansa as his wife becoming heirs, or their children the heirs, to the throne. Then Daenrys has heirs she can train and trusts though she cannot have children.
Whether Jaimie takes over Casterly Rock or Tyrion’s children inherit that, too, are TBD.
This model allows Sansa to be the mother of princes and princesses she expected to be in the beginning.