A small edit to put this answer into a broader perspective.
In a broader perspective, French acquired the status of lingua franca amongst the European powers in the areas of commerce, science and international politics somewhere in the seventeenth century, and arguably did not relinquish this status until the early twentieth (in favour of English). Now, in the case of the Ottoman empire, there is more at play than just this general development, which I hope to explain below.
You need to understand that of all Christian nations, the French have long been strategic allies of the Ottomans. This fundamentally has to do with the Habsburg ascendancy, created when both Spain and Austria (and thus the Holy Roman Empire) were under the control of members of the Habsburg family.
This implied France was surrounded by rivals, and, following an ancient adagium (the enemy of my enemy is my friend), it allied the Austrian arch-nemesis: the Turk. It also implied, given the Christian-Islamic divide, that the Christian world spoke ill of this blasphemous alliance, the Austrian emperor first among those.
Now, this whole ordeal started off concretely in 1536 with the (first) French-Ottoman alliance. It was never the first or main language at the court of the sultans, nor were Persian, Armenian or Arabic. It needs to be stressed that the Ottoman empire was truly multi-cultural and multi-ethnic: many languages were spoken within its borders, and the court merely reflected this. While they were all spoken at the court, and all were important as such, for the main matters of state, Ottoman Turkish (heavily influenced by Persian and Arabic, and not very related to modern day Turkish) was still the language of preference.
I would not argue that French was preferred over these other languages, but given that it was the language of the sole European ally the Ottomans had during the entire early modernities, it was important and it increased in importance as the power of European nations (including France) increased during this period.