Hobbit is written later as a prequel to the Lord of the Rings series. In LOTR, Gollum is the key in defeating Sauron. Bilbo's choice of not killing Gollum reflects his rejection to prejudices. "He knew, of course, that the riddle-game was sacred and of immense antiquity, and even wicked creatures were afraid to cheat when they played at it. But he felt he could not trust this slimy thing to keep any promise at a pinch. Any excuse would do for him to slide out of it." Even though Bilbo knows Gollum cannot be trusted, he chose to spare him "He must fight. He must stab the foul thing...Gollum had no sword...was miserable, alone, lost. A sudden understanding, a pity mixed with horror, welled up in Bilbo's heart." That is when Bilbo rejects his prejudices and urge to kill Gollum. Dwarves are a good and proud race while golbins are evil and wicked beings. But they both have prejudices of other beings. That has led to their mistrust of Gollum.