The treasure brings out the greed of the dwarves. It starts with Thror, whose lust for gold, silver, mythril, and other precious jewels continuously grows, until his hoard is so large that it attracts the attention of the dragon Smaug. Thror's greed leads to the loss of many dwarves' lives, not to mention their home in the Lonely Mountain, and his kingdom.
Thorin, Thror's grandson, is also portrayed very negatively due to the treasure in the mountain. He is so consumed by his need for it that he is driven mad by it. He forces the other dwarves and Bilbo (who secretly already possesses what they're looking for) to search through the hoard for the Arkenstone, aka the Heart of the Mountain, which is what Thorin is so obsessed with. He is also willing to go to war with just his twelve dwarf companions against an army of men and elves in order to keep all of the treasure for himself.
Tolkien uses the treasure to portray the dwarves in a negative light, because they seem greedy and gold-sick.
The dwarves have come to Bilbo because they are treasure hunters. There are really two ways of looking at it. On the one hand, they are just trying to get their home and what belongs to them back. On the other hand, they are looking for gold.
When Bilbo asks for more information, for example, Thorin asks him if he hasn’t been listening. Thorin tells Bilbo that the dwarves became very rich as miners, and that was what brought the dragon. It is interesting to note how he compares the way a dragon looks at gold to how a dwarf does.
Dragons steal gold and jewels, you know, from men and elves and dwarves, wherever they can find them; and they guard their plunder as long as they live (which is practically forever, unless they are killed), and never enjoy a brass ring of it. (Ch. 1)
Dragons do not enjoy their gold, they just hoard it. They do not make their treasures, they just steal them. When Thorin and the dwarves seek their treasure, it is because they want their birthright back. They are seeking their home.
This is not really the difficult part. The difficult part comes later, after Thorin and Company actually find the gold. Once they find it, Bilbo fears that they lose their reason.
There is a problem that comes with having too much gold, or coming too close to gold. It's later referred to by Tolkein as dragon-sickness.
Bard had given him much gold for the help of the Lakepeople, but being of the kind that easily catches such disease he fell under the dragon-sickness, and took most of the gold and fled with it, and died of starvation in the Waste, deserted by his companions. (Ch. 19)
Dragon-sickness basically refers to being more interested in gold than in taking care of the people you are supposed to be leading. Bilbo fears that Thorin falls under this sickness too.
Thorin refuses to negotiate with the elves and men. He will not reach a settlement, or even open peace talks. He thinks that he can hole himself up in the mountain with his treasure and his few dwarves, and he does not care what danger they or anyone else is under.
This is why Bilbo takes the Arkenstone, and brings it to the Elvenking and Bard. Bilbo fears what Thorin will do if he does not find an end to the standoff. Thorin refuses to find a compromise, and he is very interested in the Arkenstone. Bilbo knows that it will make him bargain.
Bilbo seems completely immune to the lure of gold. He cares about his friends, and his home, and a little bit about adventure itself. He took the Arkenstone not because it was valuable to him but because it was a bargaining chip he thought he could use, and use it he did. Bilbo changed a lot during the trip, and he learned to adapt.