A trivet is just a three-legged stool or table.
The name, somewhat distorted, comes from the same source as “tripod,” three footed. Anything that is three legged, as a milking stool, will stand firmly on any kind of surface.
So the phrase, right as a trivet, means thoroughly right, perfectly stable.
From the evidence of literary use, the expression is little more than a hundred years old; but the fact that Thomas Hood used it in 1835, and Charles Dickens put it into the mouth of one of his characters in 1837 indicates that it had long been in colloquial speech before those dates.