The Empire just declined because it was too backward for the changing and industrializing world... The rise of ethnic nationalism among it’s many ethnic groups, the feudal system and refusal to change lead to it’s total destruction like in every other empire. In it’s last decades it was nothing else but a laughing stock... The Sick man of Europe.
When in the other parts of the world education, science and industrialization were tolerated by the local monarchs and governments in the Ottoman empire the people in the golden palaces and the madrasas were still living in the past. As long as they were getting their share of taxes and living in luxury.
Unfortunately most Sultans after the year 1700 were not taking education and modernization of the Empire sirious. While Turks and Muslims were only used as warriors and peasants the Greeks, Armenians and Jews were getting richer, more educated. All that while Westerners were using the Empire as a de facto colony.