At the time the Dutch established themselves in the islands, the region consisted of many competing and often warring rulers. In order to protect their trade routes and their base at Batavia, the East India Company had to raise armies and get funds from local people to pay for military costs. Alliances with local rulers drew the company more deeply into the politics of the region and led it to expand the territory under its control during the 1700's.
By the end of the eighteenth century, the East India Company had gone bankrupt, in part because of dropping prices for spices
And in part because of rising expenses and financial mismanagement. In 1799 the East India Company went out of existence and all of its territories became the property of the government of the Netherlands, which was then occupied by France under Napoleon Bonaparte.
France was then at war with Britain, so the British seized Batavia in 1811. In 1816, after war between Britain and France had ended, the British returned the former Dutch territories, which had become known in Europe as the Dutch East Indies, to the Netherlands. Throughout the nineteenth century, the Dutch extended their territories in the Indies.