There are different theories, one said it came from 太皇太后 (A queen who became the Emperor's grandmother), but I seriously doubt it to be the case. From a nickname/ honorific for the Emperor's grandmother to an honorific for someone's wife is a big stretch.
The following is more believable to me.
According to this article 为何人们把已婚的女性称为“太太”？原来有“太太”这么好的寓意
“太太”, used as a honorific term for wife, was medntioned in “甲乙剩言”, and was quoted in “全閩詩話” volume 8:
only wife of higher ranking officials (中丞以上) could be called “太太”; afterwards, this term was “deflated”, that it’s used as a term for ...