Gandalf's decision to join this quest was expressed in the movie, though only slightly. During the events of The Hobbit, the threat of the 'Necromancer' in Mirkwood, is ominous. Gandalf travels to Dol Guldur, the abandoned Elvish fortress, and meets Thrain (Thorin's father), gets the map and the key, and makes a vital discovery: that the Necromancer is really Sauron.
Gandalf's primary motive is that he doesn't want Smaug to ally with Sauron.
At that moment, it is Middle Earth's most powerful creature, and its friendship with Sauron would prove costly for the Middle Earth. Hence, he prods the Dwarves into getting back their gold, thereby unfolding the events of the Hobbit.
You must understand Gandalf's move here. He wasn't interested in the Dwarves' redemption, or anything else. Getting Thorin and his company to go against Smaug, was just the first of many steps to combat the dragon. He then, along with the White Council, attacks Dol Guldur and drives Sauron away, who finally settles in Mordor. He plays his part in uniting the Men of Lake Town and the Dwarves, who eventually succeed in getting Smaug killed. The Battle of Five Armies helps get rid of the Orcs and the Goblins and the Wargs too. Gandalf was a shrewd fella. This wasn't about getting the Dwarves their gold back, it was about eliminating threats to Middle Earth. And Thorin, at least in the book, understands this.More questions on The Hobbit (book, movies and creative franchise):