Looking a “gift horse in the mouth” would be like judging the gift’s value, which is an insult. The gift may not be ideal if it is an old horse, but since it was free and you can still make good use of it, perhaps gratitude for having one at all is appropriate.
Of course this proverb is one that applies to horses very rarely. After all, when was the last time somebody gave you a horse? But it’s a proverb, and covers any and all gifts.
Horses’ teeth grow over time, as they become worn down by grazing, and develop a distinct wear pattern. Therefore, checking their length is a way of gauging age, and therefore a sign of mistrust towards the giver. Determining a horse’s age from its teeth is work for a specialist, but it can be done.
The origin of the proverb is ancient and unknown. However, in John Heywood’s collection of English proverbs, published in 1546, it appears as, “don’t look a given horse in the mouth.” Heywood may have found the phrase in a Latin text of St. Jerome, The Letter to the Ephesians, circa AD 400, where it has a slightly different wording.
Heywood himself is an interesting character. He worked at the court of Henry VIII as a singer, musician, and playwright. His book is a comprehensive collection of sayings known at the time. He collected these sayings from literary works then current and from common everyday speech. Thus he introduced many proverbs to a wide audience, including one that Shakespeare later used: “All’s well that ends well.”
It’s been suggested that the proverb might have originated from the legend of the Trojan Horse. But I can’t see any connection there. The Trojan Horse was built by Greeks to smuggle men inside fortified Troy, and they certainly weren’t going to go around telling Trojans not to look too closely at their wooden horse!