Because the word “years” comes three times the Midrash thinks that each of the ages mentioned in the verse has a special significance.
According to Rashi’s version of the Midrash, Sarah was as beautiful at twenty as at seven and at a hundred she was as free from sin as at twenty.
Another version reverses the order and says she was as beautiful at a hundred as she was at twenty, and as free from sin at twenty as at seven.
Human experience might prefer the second reading, but whichever way we take the Midrash the really important question is probably why the criteria chosen are beauty and innocence.
The answer seems to be implied in the famous 31st chapter of Proverbs, Eshet Chayil, which mentions beauty but argues that being God-fearing is more praiseworthy.
It could be that King Solomon, no stranger to the question of what makes a woman attractive, recognised that beauty is basically a gift from God but good character is the result of one’s own efforts.
Sarah had good reason to thank God for being made beautiful and for retaining her beauty, but God had good reason to thank her for being sinless.