The Edict of Nantes gave religious freedom to Protestants in Catholic France. It was enacted by Henri IV to end religious wars, but by the time Louis XIV became king, the Protestants had acquired quite a bit of power in France, despite the fact that it was still considered a Catholic country. It is not certain exactly why Louis revoked the Edict. For some time, historians believed that Louis XIV's second wife, Madame de Maintenon, was responsible for goading Louis to revoke the Edict, but this theory has lost some credence of late. It is now believed that Louis XIV could have revoked the Edict to placate the Catholic Church, angry over the many restrictions that the king had placed on the church. Also, the Turks had been defeated in the Austro-Turkish war in which France had remained neutral, so some feel he may have been trying to restore prestige to France with the other European Catholic nations. Finally, when he was crowned king, he vowed to end heresy in France (France had been plagued by decades of religious wars between Catholics and Protestants), so this also could have been a reason. Louis had made life miserable for Protestants in France prior to evoking the Edict of Nantes. Many of them had left for other countries. In France, Catholics were forbidden to marry Protestants, and the Protestants were not allowed to hold positions in court, among other restrictive policies.
The Edict of Nantes, developed to end the religious wars that tore through Europe in the wake of the Protestant Reformation created what was almost a Protestant state within France. This posed several difficulties for Louis XIV, primarily financial and diplomatic. On a financial level, the French kings, under a theological movement known as Gallicanism, has been able to gain practical control of appointment of many Roman Catholic bishops to important positions within the Roman Catholic church in France and thus gain access or connection to the vast wealth of church lands; Protestant church lands were out of monarchial control. Also, Louis XIV wanted to centralize administrative power rather than letting it be dispersed -- and French Protestantism allowed for an enclave of regional autonomy. Finally, by revoking the Edict, Louis XIV could curry favour with the powerful Papacy (which that that time was the head of the Papal States and thus a temporal as well as religious power) and strengthen alliances with other Catholic nations against historic Protestant enemies. By driving out the Huguenots, Louis XIV severly weakened the French economy and increased tensions with Protestant countries.
Now-days, the government relies on schools and TV to inform, guide, propagandize, and mold the opinions and attitudes of the people. In Louis XIV's time, those functions were performed by the Church. The king could issue a decree and the priests would all read it in their churches. The Catholic Church and monarchy had evolved together. They supported one another.
In England, King James I told Puritian petitioners who wanted the episcopal Church of England altered into a presbyterian church, "A Scottish presbytery agreeth as well with monarchy as God and the devil." This was probably also the feeling of Louis XIV. (Some historians have said that the American War of Independence was a Presbyterian rebellion. Presbyterian churches are governed by the people of each individual church; the Catholic church is governed by a Pope and Cardinals, much like a country was governed by a king and his ministers.)
Donald Kagan, et al, in their textbook The Western Heritage since 1648 (1979), give it as Louis's reason, that a country could not be under one law and one king unless it was also under one religious system. They also say that until the time of his death, Louis thought he had done a great thing for which "God was indebted to him."