Why did Bilbo steal the cup in The Hobbit?
There's many different reasons behind Bilbo's theft. One has to do with the similarities between Tolkien's story and the epic poem Beowulf. Tolkien was an accomplished scholar and translator, and English literature fascinated him. Textual similarities between each scene of conflict with the dragon confirm Tolkien’s statement that “the episode of theft arose naturally (and almost inevitably) from the circumstances.” In each tale, the conflict arises after a cup is stolen from a mound of treasure, which enrages the dragons, to which the treasure does not originally belong. Each dragon is likened to a giant worm and presented as bloodthirsty and destructive, ruining nearby villages.
It also be just simple greed. Who wouldn't be tempted when surrounded by that treasure? When Bilbo sees the hoard:
His heart was filled and pierced with enchantment and with the desire of dwarves; and he gazed motionless, almost forgetting the frightful guardian, at the gold beyond price and count.
Thus he willingly took the risk. After all, didn't Gandalf appoint him the "burglar" of the group? He was simply living up to his job title.