In The Hobbit by J. R. R. Tolkien, Bilbo Baggins, and the hobbits in general, are meant to exemplify the virtues of the Anglo-Saxon yeomanry and peasantry. They are not the "great" folks about whom most heroic tales are written, but, as Gandalf points out, they have a distinct set of virtues, which Biblo exhibits when he stays with the dwarves. They are extremely loyal, capable of strong bonds of friendship and community. They have remarkable powers of endurance. When things are going well, they enjoy simple pleasures and may seem lazy, but when the going gets difficult they display strength and courage in the face of adversity, and they are very stubborn. Bilbo has become friends with the dwarves and stays out of loyalty and also a new found pride in his own abilities to fulfill his bargains.
Bilbo has several commendable qualities which cause him to go on with the dwarves rather than leave them when Gandalf leaves them. Chief among these are honor and tenacity: a Hobbit of his word, Bilbo will not desert the dwarves simply because their journey has become dangerous; his tenacity serves him and the dwarves well. He shares the Hobbits' love of riddles; the dwarves' quest proves to be a continual source of riddles and solutions, and his riddling skills save lives more than once. Finally, Bilbo has a rather unHobbitlike imagination and love of tales, and every adventure feeds his desire to learn more, to LIVE an adventure rather than reading or hearing about it. Leave with Gandalf? Not when adventures, tales, riddles, and possibly treasure await him!