Why did Bilbo give away the Arkenstone to Bard?
Your question touches on a key point in the story and is another example of the heroic nature of Bilbo. We see when the company arrives at the mountain that Thorin in particular becomes obsessed with gold-greed but also with finding the Arkenstone - an incredibly valuable jewel that is very important to his race and family. When news comes that Smaug is dead Thorin determines to protect the dragon hoard and not give any of it away, even if it means war and death. Bilbo is not taken in by this greed and can see Thorin's failing in this regard. He decides to bring this imminent catastrophe to a peaceful conclusion by taking the Arkenstone and giving it to Bard as a bargaining chip - he knows that Thorin will do anything to get the Arkenstone and thus he realises he can force Thorin to part with some of his treasure to gain the Arkenstone.
Of course, it is important to realise how this represents a further development in the character of Bilbo. Note how he is not now saving his own life as with his encounter with Gollum. He is also not now saving the lives of his company in the incident of the spiders and the escape from the halls of the Elvenking. He is now preventing death and war between three races through his heroic actions. This incident then represents the development of Bilbo from comfort-loving Hobbit to hero who saves others through his exploits.
Because Bilbo knew that Thorin was not being open-minded or fair. Bilbo wanted long term peace between Dwarves and Elves and Men. But Thorin was not prepared to share and wanted to be greedy and selfish.
So Bilbo gave the most important thing in Thorin's life (the arkenstone) to Thorin's 'enemies'. That way Thorin had to talk and negotiate and be sensible.