Without going into excruciating detail about allegiances to dukes, lords and kings, it is hard to explain the origin if this rather unique set of international borders. Suffice it to say that the land was bought, sold, and loaned through many generations to the point where the current land owners felt allegiance to either the Dutch or Belgian side of the border. When it came time to make the border official as art of the 1843 Treaty of Maastricht, 5732 separate parcels of land had to have their nationality laid down separately.
Fortunately the borders are all friendly. In fact, there were several opportunities to clean things up in subsequent treaties and negotiations that the residents refused to act on. The residents of Baarle-Nassau seem to enjoy their quirky borders and the ramifications they present.
There is at least one border line that passes directly through a building. With borders sometimes passing through the middle of properties, taxes were sometimes a challenge in the area. To clarify matters, the Dutch government set the rule that taxes would be paid to the country your front door opened up on. With taxes being higher on one side of the border than the other, the ruling was an invitation for creative renovations. If shop keepers didn't like the taxes they were paying, they were known to just move their front door so that it opened on the other country.
The primary border between the two countries lies about 5 kilometers south of Baarle-Nassau... just a short distance beyond the bottom of this map. What is truly unique about this set of borders is that it happens completely inside the Netherlands border. These are Belgian exclaves inside the Netherlands. But even more amazing is that there are Dutch exclaves completely inside the Belgian exclaves. The smallest plot, identified as H12 is just 28,331 square feet (a bit more than 1/2 an acre) in size. With all of the dysfunction between Israel and the Palestinians over land swaps, it is nice to see two countries getting along so well that there's no need to swap.
Sources: University of Buffalo , Wikipedia