As the link to Phrase Finder above explains, this phrase evolved from the phrase filthy lucre from the 1500s. Here's what Etymonline has on lucre:
late 14c., from L. lucrum "gain, advantage, profit; wealth, riches," from PIE root *lau- "gain, profit" (cf. Gk. apo-lanein "to enjoy," Goth. launs, Ger. lohn "wages, reward," and possibly Skt. lotam, lotram "booty"). Filthy lucre (Tit. i:11) is Tyndale's rendering of Gk. aischron kerdos.
As Phrase Finder explains:
Following on the the term "filthy lucre", money became known by the slang term "the filthy", and it isn't a great leap from there to the rich being called the "filthy rich". This was first used as a noun phrase meaning "rich people; who have become so by dishonourable means".
Phrase Finder claims a 1920s origin, but the two words can be found together in print from the early 1800s. This, however, is the earliest example I can find of it being used as a set phrase rather than as a description of rich people who are physically dirty. Here's a clip from A Certain Rich Man by William Allen White, 1909 (date check):
And a final point worth noting from Phrase Finder:
As time went on the negative associations have softened somewhat. It has become to mean "extremely rich" rather than "dishonourably rich", although there may still be a trace of an unfavourable implication associated with it.