Samuel Johnson wrote it in his life of the poet Abraham Cowley, part of Lives of the English Poets (1779–81). He means that words are the clothes a thought is dressed in — and that a fine idea put in cheap, careless words loses its dignity.
What it means
Your words are how your thoughts appear in public. Johnson's point is sharper than the short version suggests: the right idea in the wrong words — too common, too careless for the occasion — is diminished, the way a noble figure would look ridiculous in working clothes.
Where it comes from
The line opens a sentence about poetic diction. In full, Johnson writes: “Language is the dress of thought: and, as the noblest mien, or most graceful action, would be degraded and obscured by a garb appropriated to the gross employments of rusticks or mechanicks; so the most heroick sentiments will lose their efficacy, and the most splendid ideas drop their magnificence, if they are conveyed by words used commonly upon low and trivial occasions, debased by vulgar mouths, and contaminated by inelegant applications.”
It is usually quoted alone, as a general truth about writing. In context it is a criticism: Johnson is explaining why some of Cowley's grand ideas fall flat — they are dressed in words that are too ordinary for them.