Where Bilbo lives is a very comfortable and law abiding place. As we get further away from home things get wilder. The Hobbit is of course a children's book and Tolkien makes things as simple for his youthful audience. He designates this area as 'the Wild'. This is fairly easy on the brain and gets us to the right place mentally with minimal effort.
We aren't far into the book before we get to the first adventure. Gandalf has disappeared without explanation - he does this a lot - and the dwarfs have run short of food after an unfortunate incident where the pony with the supplies falls into a river. We have already worked out that Bilbo is a novice adventurer but we now begin to realise that the dwarfs are not a lot better. But as luck would have it, as night falls they see a fire in the distance. Bilbo in his capacity as the burglar is sent ahead to try and locate some food.
It turns out that the fire is a troll camp. Trolls are evil creatures so there is no moral problem with stealing their property which Bilbo proceeds to do by pick pocketing a purse. He very consciously regards this as a start to his career as a burglar But as Bilbo might have been expected to know already we are in a world where magic needs to be allowed for. The purse has both a level of consciousness and loyalty to its owner, and on being stolen it announces the fact. This provides both a convenient plot device and prefigures the invention of the car alarm. Bilbo is captured.
This gives us a chance to get to know the trolls. There are three of them and they are called Bert, Bill and Fred. These names sound a bit old fashioned now, but would have been perfectly standard at the time Tolkien was writing. We even get one of their second names.
The language the trolls use is reminiscent of working class stereotypes from the time Tolkien was writing. To get an idea have a look, or more particularly a listen, to the way the great Stanley Holloway talks in this clip from My Fair Lady.
One of Elmore Leonard's rules for writing fiction is to avoid the use of regional accents or patois. It's a sound enough rule most of the time, but Tolkien does it with such great skill he has to be forgiven. I love the way the trolls' conversation is dealt with. "Yer can't expect folk to stop here for ever just to be et by you and Bert. You've et a village and a half between yer, since we come down from the mountains. How much more d'yer want?". The well meaning liberal in me wants to disapprove of this apparent mockery of lower class diction, but I am obliged to respect how well he captures it. And of course nobody speaks like that any more.
It is easy to imagine the origin of the trolls in Tolkien's mind as big grown ups from his own childhood. In fact his conception of trolls is rather different from how I remember thinking of them as a child. Trolls were not large and lumbering, but small and vicious. They would hide in particular places and would be ready to eat you if you failed to meet a particular formula. For instance there was supposed to be a troll that lived under a footbridge over a nearby railway. If you tried to get across the bridge on your own this particular troll would eat you if you didn't know its name. (I didn't). Another one lived in some gooseberry bushes and would eat you if you ate unripe gooseberries. So trolls were sort of agents of instant retribution for misbehaviour.
Given how popular Tolkien's works have become, I wonder if the traditional view of trolls has now changed to match his. The trolls in the Hobbit are unpleasant but in a comical way. They will eat you, but they will have a debate about the best way to cook you first.
And although they are tough, tough enough to deal easily with the Thorin Oakenshield even when he is armed with a flaming branch, they aren't all that bright. Despite this the dwarfs' rescue attempt is a total disaster with all of them being captured. It is only Gandalf's return that saves the dwarfs. By imitating the trolls' proletarian voices he keeps them arguing until the sun comes up. It turns out that sunlight turns trolls to stone.
Luckily the trolls were not only too stupid to notice that the sun was about to rise, they also had relatively poor security measures on their troll cave. Bilbo had found the key to it enabling the party to ransack it for vital supplies for later in the quest. In fact the troll cave really does provide everything that is needed. It is well stocked with food to replace what was lost in the river. They also pick up a couple of handy looking swords.
This short incident brings out several of the recurring themes of Tolkien that can be seen in a lot of his work. First off, the tendency of evil to be self-defeating. At the end of the day the trolls undo themselves by being argumentative. A good bit of socialist co-operation and comradeship would have had the dwarfs minced and half way to being made into pies well before the trolls had to take shelter from daylight.
Also, setbacks have a habit of proving to be great advances in disguise. The swords are to prove very useful later in the quest. But above all, we see the characters growing as a result of adversity. The dwarfs and Bilbo will be a lot more professional and hardened when they run into their next adventure. It is almost as if there is some plan afoot by a higher being to train them for some higher purpose.