Octroi" comes from the Old French "octroyer" which means to grant or authorize and this type of tax has existed since Roman times. In Versailles, however, it lasted until the 20th century when it was finally abolished because:
Freinant le développement d'une économie moderne et mal accepté par la population, l'octroi sera finalement supprimé par arrêté municipal en février 1943 et remplacé par le relèvement des taxes locales sur les ventes au détail et les prestations de services.At that point the buildings were abandoned and it was even proposed that they be torn down since they served no purpose and because that intersection is a real accident magnet even today. But in 1958 they were put on the list of Monuments Historiques and preserved. Today they host offices for non-profit organizations and a library.
Slowing development of a modern economy and poorly accepted by the people, the octroi tax was finally eliminated by a municipal act in February of 1943 and was replaced by sales tax on goods and services.
They are also the favorite place for the local cops to catch people speeding. The Avenue de Paris is a wide, long, straight stretch of road and people have a tendency to put the "pedal to the metal" as they drive away from the castle back to Paris. Every weekend the cops set up a radar right next to the octrois and rake in revenue for the city.
So, if you are planning a day trip to see the Hall of Mirrors and the Versailles gardens, do yourself a favor, leave the car at home or at the hotel and take the train. Otherwise you might end up closer to the octrois then you would like, explaining yourself to the local cops and paying a very modern tax (an expensive speeding ticket) in order to leave the city in peace.