So, amazingly enough, I have read online that there are people who think that Bilbo's actions in this chapter are morally suspect. Giving the Arkenstone away to Bard and the Elvenking seem to them like theft, pure and simple, and thus dishonorable. Upon reading this, my first thought was, "these cannot be people who have thought seriously about war." Although, who knows, maybe I'm wrong about that.
I think it's pretty clear that, given what Bilbo knows (which does NOT include the fact that a goblin and warg invasion force is headed their way), war between the dwarves and their neighbors is inevitable. That would be an awful, horrible, bloody mess, even if it did not get followed up by a goblin/warg invasion (which it in fact would have). Whether or not Bilbo's plan ever had a chance of working, it was the best option he had to try to rescue the dwarves (and men and elves) from their own worst instincts.
It should also be remembered that Bilbo DID have another option for himself. He could have simply filled his backpack with loot (perhaps leaving the Arkenstone in some dark corner to be found by the dwarves later), and said "see ya" and walked out. The dwarves had no claim on him any more, his backpack would have held far less than one fourteenth of the hoard while still being enough to be worth his while, and in any case the dwarves probably knew he would not be worth much in a siege. They would not have been able to keep him, and probably would not have tried to. Getting back home would be challenging, but maybe not that challenging with a ring that makes you invisible and a backpack full of gold. That he does not take this option, and even goes back to the dwarves after giving away the Arkenstone, is an act of extraordinary decency.
As for Gandalf, I think it's more clear what he's thinking. I believe he does know that a goblin and warg army is coming, and his primary concern is probably how on earth he can delay the fight between dwarves and elves/men until the goblin/warg invasion makes them allies. He may know that the Arkenstone will not prevent a war between dwarves and elves/men in and of itself, but if it may help to delay things, by giving Bard and the angry, hasty Men reason to think they don't need to try a frontal assault. Otherwise, as soon as they found out about Dain, they might have thought they needed to give it a try because if they didn't get in before Dain arrived they never would get a share of the treasure. That would probably have resulted in the deaths of all 13 dwarves, and many Men (and elves too, if they decided to take part), plus souring (permanently?) the relations between them.
Of course, it isn't actually going to work, in the sense that it won't prevent Thorin and Bard from rushing into preparations for combat. But I certainly don't fault Bilbo for trying.
This whole turn of events is in some ways highly non-traditional, when compared to ancient hero-sagas. But, in another sense, it is traditional that dragon hoards are trouble. Beowulf's end comes from a servant of his stealing a cup from a dragon's hoard, and generally there are plenty of tales where a dragon's hoard brings trouble after the dragon is slain. It looks much like Bard, the dragon slayer, is playing the part of the traditional hero, but what is different about JRRT's tale is that Bard is not the central figure of the story. It is Bilbo who is the protagonist, and his primary concern by this point is to get home to a quiet breakfast in Bag End. Not yet.
Chapter 17