To understand its fall, you have to understand its rise. I don't usually like using the terms rise and fall with empires, but, it helps to divide the eras of growth and shrinking. It became the most powerful state due to it's land acquisition and the efficiency and size of its bureaucracy. Several factors distinguishing it from other Islamic empires in the region led to its superiority, but, I'd argue the distinct rise of the Ottoman Empire began with Mehmet II's (1451-1481) conquering of Constantinople in 1453. Not only was this an important act of land acquisition, it showed superiority of Ottoman weaponry, which is why it is referred to as one of the gunpower empires of the period. Similarly in 1517, Selim I conquered Jerusalem, Mecca, Medina, and Cairo (the capital of the Mamluk Caliphate of Egypt), which not only gave the Ottomans more land, but, gave them a strong religious presence in the Middle East because the Sultan could also claim the title of Caliph. This was used by the few sultans after Selim I to garner unity among its Arab provinces, further increasing the strength of the empire. Statebuilders like Suleiman the Magnificent (1520-1566) (whose reign is regarded as the peak of the empire) helped to achieve more efficient bureaucracy throughout the empire by reforming taxes; he also helped by reforming the empires form of Islam to something resembling the Hanafi school of Sunni Islam, which is known for being the most accepting of non-Arabs and non-Muslims, which actually made up a large percentage of the Ottoman population (mostly in Palestine, Rumelia, Serbia, and Anatolia). Other institutions such as the Devsirme helped to increase the efficiency and strength of the Ottomans as a whole. The Devsirme was an institution of enslaved Christian boys, usually from Rumelia, who were given the best educations i nthe world, and depending on whether their proficiencies were academic or physical, were made government officials or recruited into the Janissary corps, forming intelligent and strong politicians and armies.
The decline is often seen as starting with Napoleon's invasion of Egypt in 1798 just because it showed that Europe had achieved military superiority in the century prior. While England and France never went further into the Ottoman Empire, they were now getting the Economic benefits of the Ottoman's North African provinces, weakening the Ottoman financial state. Also, with the revolutions going on around the world in the prior decades, the rise of nationalism was spreading throughout Europe, and the European provinces of the Ottoman empire began revolting in the early nineteenth century, and they eventually lost Greece and Serbia to revolutions inspired by nationalistic sentiment. From 1300 until the 1790's, the Ottomans were too proud to send ambassadors to any European countries because they felt that Constantinople had more important business than London or France. Selim III in the 1790's finally sent ambassadors to France, London, Berlin, and Vienna, showing a shift in international politics that the Ottomans were no longer the biggest, best empire.
By the nineteenth century too, the Janissaries, the pride of the Ottoman Empire, became entirely nepotistic. As a result, Selim III (1789-1807) tried to abolish them in 1806, hoping to institute a new, European trained army known as the Nezam-i Cedid (New Order). The Janissaries ultimately felt threatened and ended up deposing and killing Selim III. Mahmud II (1808-1839), his successor, didn't make the same mistake and had all the Janissaries slaughtered in 1826. By this point, the Ottomans now lost their most advanced military after a Sultan had been murdered by the soldiers sworn to protect him.
The same year Mahmud II died, Rashid Pasha, one of the Ottoman governors, wrote an edict called the Hatt-i Serif of Ghulane, which essentially proposed standard military drafts, protection of honor and property, and equality of all Ottoman subjects regardless of ethnicity or religion. This document started an era known as "Tanzimat" (reorganization) in which intellectual elites from Constantinople pushed for a constitutional government. They were mostly ignored, though continued to demonstrate, for about 35 years. When Sultan Abdulhamid II took the throne in 1876, he instituted the constitution, which followed the same ideas as the Hatt-i Serif, but retracted it 2 years later, ending the First Constitutional Era. In the late 1870's, the Ottomans lost even more land, almost the entirety of their Caucus population, to the Russian Empire. They were now reduced to Anatolia (modern day turkey) and Arabia in effect.
By the twentieth century a new group of exiled intellectuals (based mostly in Paris) called the Young Turks (formally the Committee of Union and Progress) formed and continued to demonstrate throughout the decade. They overthrew Abdulhamid II (1876-1908) in 1908, made their party leaders the head of the Ottoman government, and appointed the new Sultan as nothing more than a figurehead. The inexperienced leaders thought they would do good by ending strings of nepotism throughout the Ottoman empire's provinces, namely the Arab ones (where Abdulhamid had spend 3 decades securing loyalty and trust among Arab leaders). Removing influential governors from power around the provinces, they lost most of the support they had from the remaining territory they had.
Ultimately, they only entered World War I because they wanted to regain the land they lost in the Caucuses 4 decades before, but, were ultimately unable to do that, and were too frail to survive the war having lost most of their land, money, and military in the decades prior.
Edit: An important factor to mention about them being viewed as the "sick man of Europe" is that England and an Ottoman Arab Emir in Mecca had secret correspondence regarding a planned revolt within the Empire that was meant to overthrow the Committee of Union and Progress and allow the British to take power of Anatolia after that was done. Because of this, Europeans became more aware of how little the population of the Ottoman empire actually agreed with the ruling class. Look up the Hussein-McMahon letters and the Arab revolt to look more into it.
For more information like this, look at:
A Concise History of the Modern Middle East by Arthur Goldschmidt and Lawrence Davidson
and
A History of the Modern Middle East by William Cleveland and Martin Bunton.
Edit 2: Also, if there are any further questions about any specifics, please ask. I love this topic.
Edit 3: Thanks for the gold, anonymous reader!
Edit 4: /u/ilovethosedogs and /u/UmarAlKhattab have made some corrections in my chronology, be sure to scroll down to see them!
Edit 5: The rest of the information I've received was from lectures by an amazing professor with a Doctorate in Ottoman History.
So this is going to be long...
As has been noted, three centuries is an incredibly long time. The short answer is that by the late 17th century other Powers had surpassed the Ottoman Empire in military strength, including Austria, who had designs on Ottoman territory.
There were of course internal problems as well. The janissaries were no longer an elite fighting force, as they had secured privileges such as maintaining jobs (and thus neglecting their training) and getting their sons admitted into the corps. Thus, by the late 18th century when Selim III created a new, modern army, the janissaries were more a drain on the Ottoman treasury than anything -- as an aside, it is kind of amusing to note that in Turkish 'janissary' is 'yeniçeri', which means 'new army/soldier' while Selim III's new army was called the 'nizam-ı cedid' or 'new order' as it was a part of Selim's reform projects, so it was basically the 'new army' to replace the 'new army.' Similarly, previously sipahis (cavalrymen) who received the right to the income of land (timar) were required to maintain a certain number of cavalrymen (depending on the size of the timar) who would join the Ottoman armies as requested. Originally, these sipahis could be moved every couple years to a new timar to prevent them from building up a local power base, but this practice stopped and sons began inheriting their fathers' timars, giving them a more legitimate claim to land ownership, and yet neglecting their military duties.
The proliferation of guns also facilitated banditry, and worse, Ottoman notables (ayan) were able to create personal militias/gangs to control their locality and essentially ignore Ottoman central authority. Many of these ayan also entered into tax farming -- the Porte was often desperate for cash, and would auction the rights to tax revenue -- and these tax farmers would use their militias to extract as much as possible from the populace, thereby fomenting rebellion. There really wasn't a great solution to this either so long as the Porte did not have the coin ready to enforce central authority. They tried giving long-term tax farms so that tax farmers would not exploit their holdings too much, but this just entrenched ayan power.
But going back to external threats, I would trace the origin of European predominance within the Ottoman Empire to slightly before Napoleon's invasion of Egypt, with the signing of the Treaty of Küçük Kaynarca in 1774. Not only did the Russian victory prove its military superiority, but the terms of the treaty gave Russia the pretext to intervene between the Sultan and his Orthodox subjects. In reality, at the time of the treaty, Russia really only gained the right to make demonstrations to the Sublime Porte regarding the running of the church which it had received permission to build in Constantinople and some rights to remonstrate regarding the administration of Moldavia-Wallachia (today Romania). But when Russia published the text of the treaty in French (it had originally been written in Ottoman Turkish, Russian, and Italian, with the Italian version serving as the official treaty), it had either intentionally or on accident the translation implied much broader rights for the Czar to intercede on behalf of all Orthodox Ottomans, if not all Ottoman Christians. Because it was this French translation published by Russia that was most well-known, the other Powers tended to accept Russian pretensions. (If you want more specifics, lookup Roderic H. Davison's article on this treaty. As someone whose MA thesis is on Ottoman diplomacy and my dissertation will be as well, he is by far my favorite historian).
That many of the European Powers were militarily superior to the Ottoman Empire was again demonstrated by Napoleon's invasion of Syria and Egypt. At the same time, Great Britain's support in driving out French forces showed the Porte a way to survive: gaining the support of a stronger Power (most often Great Britain) by manipulating Great Power rivalries, and then using this peace to reform the Ottoman government and military so that it could compete with the other European Powers.
While Selim III had been toppled by the members of society who most benefited from Ottoman "backwardness" (janissaries, ulema, and some palace functionaries), his hopes for reform did not die out with him. Muhammad Ali Pasha of Egypt, the Sultan's nominal vassal, had used European loans to reform his bureaucracy and military along a Western European model, which enabled him to defeat the entrenched Mamluk class and put down the Wahabbi revolt in the Arabian Peninsula for Mahmud II, the new Ottoman Sultan.
Thus, when Greeks revolted against the Ottoman Empire in 1821 and Ottoman forces failed to defeat the rebels, Mahmud again asked Muhammad Ali for his help. Muhammad Ali sent his forces under the command of his son, Ibrahim Pasha, who would have shortly ended the rebellion were it not for Great Britain, France, and Russia. The Ottoman Empire had barely avoided war with Russia during the first year of the rebellion, and it was primarily through its successful use of diplomacy with Great Britain that the Porte had (temporarily) avoided another disastrous war with Russia. So finally, with Muhammad Ali putting down the Greek rebellion, in 1826 Mahmud decided it was finally time to reveal his new army, with Western military tactics and discipline. As feared, the janissaries rebelled, but Mahmud was able to destroy them.
But Europe was not pleased with the success of Egypt's armies in Greece, fearing that Muhammad Ali had been promised rule over Greece and was thus seeking to kill Greek Christians. Consequently, Great Britain, France, and Russia sent a combined fleet to destroy Ibrahim Pasha's ships, prompting Ibrahim and Muhammad Ali to agree to withdraw their forces.
Mahmud still refused peace, and when Russia attacked, no European Power would ally with the Ottomans. Russia again won, and in the Treaty of Adrianople in 1829, Russia gained the right to send commercial ships through the Dardanelles, occupy Moldovia-Wallachia until the Ottomans paid a large war indemnity, and forced the Porte to accept the autonomy of Serbia and Greece. A few years later Greece gained its independence, however, as Great Britain and France believed that an independent Greece was less likely to become a Russian client, and Mahmud was desperate to curry favor with Western Europe to help him in his war with Muhammad Ali, who was demanding control over Syria.
Egypt's forces, again under the command of Ibrahim, looked ready to march on Constantinople and potentially depose Mahmud. Mahmud begged for assistance from Great Britain and France, but both refused -- the former because of Ottoman actions during the Greek rebellion, the latter because she favored Muhammad Ali. Only Russia offered aid, which Mahmud eventually acquiesced to seeing no other options. Ibrahim never marched on Constantinople, but Russian forces did not leave until the signing of the Treaty of Hünkâr İskelesi, which essentially gave Russia control of the Straits by granting her the right to have the Sultan close them to foreign warships should Russia desire.
This prompted Lord Palmerston, who feared that Russian suzerainty over the Sultan could threaten British interests, particularly in India, to advise the Porte to reform its government so that Great Britain could support her in the future. As a result, the Ottomans started using their efforts to reform their economy, administration, and military in their diplomatic rhetoric with Europe, to prove to potentially friendly Powers like Great Britain that she would treat her Christian subjects well and would not become a pawn of Russia. To this end, Mahmud also established permanent embassies in the major European capitals, and founded the Tercüme Odası (Translation Bureau) to teach Ottoman ministers French and prepare them for entrance into the Ministry of Foreign Affairs. That decade Mahmud also signed a trade convention with Great Britain, which did succeed in giving Great Britain an economic interest in upholding Ottoman sovereignty, but the influx of manufactured British goods harmed Ottoman craftsmen and further pushed the Ottoman economy into primarily being an exporter of raw materials and an importer of finished European goods. Ottoman industry did continue to be developed of course, but this undermined and retarded the process.
In 1839, Mahmud thought that his reforms would enable him to defeat Muhammad Ali. He died before his forces lost yet again to Muhammad Ali, but because Mahmud had created a better relationship with Great Britain, the British, Russians, and Austrians prevented Muhammad Ali from taking over the Empire (Russia especially feared that Muhammad Ali would revitalize the Empire and thus harm Russian interests). The new sultan, Abdulmecid, followed in Mahmud's reforming footsteps and promulgated the Hatt-i Sherif of Gulhane, which promised to protect and improve the lives, property, and honor of all Ottoman subjects. Abdulmecid and many Ottoman officials truly desired this, but the timing of this decree showed that the true intent was to induce the European Powers to treat the Porte favorably, which it did by severely curtailing Muhammad Ali's authority and military potential.
To the excellent responses on here, I just wanted to add that environmental historians have started to investigate the role of the Little Ice Age in shaping social dynamics in the late 16th and 17th centuries. This climate event led to wetter conditions in Europe, and droughts in areas of the Middle East that the Ottomans depended on for agriculture, among other issues.
Check out The Climate of Rebellion in the Early Ottoman Empire: An Environmental History by Sam White (Cambridge University Press, 2011)
The Hapsburg King Charles V, aka King Charles I of Spain, deep water navigation. Portuguese harassment in Middle Eastern/Southern Asian ports and monopolies, too many ethnic divisions, and most importantly, the Middle East is not the best place for industrial revolution. So, they lost.