In a phrase, Great-Power maneuvering. What is now Belgium had, before the Revolutionary and Napoleonic wars, been the "Austrian Netherlands", part of the Habsburg imperial domains. The French annexed it in 1795 in the Peace of Basel. Naturally the Vienna peace conference, at which the Powers were pretty strongly motivated to weaken the nation they'd just spent twenty bloody years fighting, wasn't going to let that stand; but what to do with the place? Austria couldn't defend it against France, as had just been demonstrated, but nobody wanted to create yet another minor country for France to kick around. (Sure, France was prostrate at the time, but the delegates were looking twenty and thirty years ahead - much smarter than their descendants at Versailles, to be sure.) So instead, they handed it to the Netherlands. This served the same purpose as giving Prussia territory in the Rhineland: It strengthened a minor power, thus contributing to a better balance of power; and it gave the strengthened power an incentive to oppose France. In the case of Belgium, it also kept Antwerp, then as now a major port, out of French hands. France had been, and might be again, a major naval power that, from Antwerp, could threaten the Royal Navy in the North Sea. The Netherlands, though it had fought naval wars against Britain in the past, was unlikely to become a major naval power again; and anyway they already had good North Sea ports, so another one didn't matter so much.
You'll notice, of course, that nowhere in this did I say anything about what the Belgians wanted...
...so in 1830, the first wave of the nationalist and socialist risings of the nineteenth century hit. There was the November Rising in Poland, which Russia crushed; and the Belgian Revolution, which the Netherlands failed to crush. The Belgians were linguistically, religiously, and ethnically separate from the Dutch, and basically didn't want to be ruled by them; a classic nationalistic rising. The Netherlands, instead of sending in the army (which would be expensive and bloody), appealed to the Great Powers. But now France wasn't so prostrate anymore, and saw advantages to splitting the medium-sized country that had been established on their northern border for the express purpose of keeping an eye on France, into two small ones, one of which might be friendly. Since nobody else cared that much (except that Britain still didn't want the French to just annex Belgium), the French had their way to the extent that the conference recognised Belgian independence. The Dutch then tried to fight; France intervened, and the resulting "war" is known as the "Ten Days' Campaign". In 1839, the result (Belgium independent of both Netherlands and France) was nailed down by the Treaty of London, by which the Great Powers guaranteed Belgian territory and neutrality, and Belgium agreed to be perpetually neutral. This was the famous "scrap of paper" of 1914.
As for Flanders, I have no idea.