ride the gravy train: achieve financial success or the easy life, especially without working for it
Gravy has meant easy money since the beginning of the twentieth century. Eric Partridge's Dictionary of the Underworld defines the word succinctly as "loot." Gravy can also refer to an easy job with generous pay. Popular variants during the first half of the twentieth century were board the gravy train and board the gravy boat, but both have become obsolete in recent decades.
Gravy, a word borrowed from French, has denoted a sauce since late medieval times. Another sense of the term refers to the juices that cook out of meat. In other words, gravy is a desirable culinary by-product gained without special effort. Just pop your roast into the oven and it automatically exudes gravy. It's easy to see how this meaning could be extended to cover money that seeps into your pocket without effort on your part.
The point of train is less obvious. Perhaps riding the train is meant as a metaphor for a quick, smooth progression from poverty to riches. The phrase could also be influenced by get a free ride, which has meant to gain an undeserved benefit or achieve something at the expense of others since the 1880s.
Besides money, gravy can refer to free goods, such as sample products, or more than you need of something good, such as one more "A" than you need to graduate. A common way of summing up these extra benefits is -- The rest is gravy.
Read more about this expression in Let's Talk Turkey: The Stories Behind America's Favorite Expressions (Prometheus, June 2008).