The short answer is that China – much like its minor satellites Japan and Korea – entered into a relatively long period of isolationism at just about precisely the wrong historical moment, leading to a rapid technological eclipsing by the West that all parties of East Asia found themselves scrambling to make up for in the mid-to-late 19th century. The somewhat longer is as follows:
Now to be clear, the real isolationists had come well before the 19th century, specifically under the Ming Dynasty of the 14th-17th centuries. Toward the end of the Yongle Emperor’s reign in the early 1420s, and certainly by the accession of the Ming’s third monarch, the Hongxi Emperor, in 1424, China had begun the process of turning inward – most notably with the order promulgated in 1421 suspending any further expeditions of the great Baochuan treasure fleet under the command of the (eunuch) admiral, Zheng He. Hongxi would deign to allow Zheng one last “hurrah” in the form of his 7th and final voyage in 1430, but the calligraphy was already on the wall: Ming China had taken the weight and measure of the world beyond its doorstep, and it had been found wanting. The voyages were deemed too costly, and (barring certain exotic pets) with relatively little to gain from such expeditions. The thing was (and in many cases yet remains) that China needed relatively little from the rest of the world. Sure European transparent and bent glass was nice and certainly made astronomy much easier and more precise, that strange monotheistic religion about a carpenter from the Mediterranean was a curious pastime for some, and – as I get into further in a minute – New World Spanish silver was all the rage… but really the rest of the world had relatively little of interest or need to China (which is certainly not to imply the inverse to be the case whatsoever!) The fact of the matter was: why should China feel compelled to go to the world… when the world was clamoring over one another to get access to the goods and technology it alone possessed?
Moreover, trade in general was viewed (at least from the officialdom) though the revitalized ethos of neo-Confucianism – which is to say, it was regarded as little more than a necessary evil that must be tolerated but never rewarded or lauded. Merchants were considered the scum of the earth, and no self-respecting official would ever stoop to handling money (though they would, of course, circumvent this by simply having their servants buy stuff for them… convenient, that). This general ambivalence toward foreign trade was further complicated by the frequent raids by Japanese/wokou pirates all along China’s one-and-only coastline (thereby bringing the long and cherished tradition of giving those islands the stinkeye from the mainland to a resounding middle). This, of course, meant that China would need to provide effective security for its merchants and fishermen, and - sigh - I guess we’ll protect the foreigners, too, if we must. Trade was not completely cut off over the course of the Ming, but it was severely restricted and curtailed, limited only to Macau (which was occupied by Portugal in the mid-1500s up through 1999) and Guangdong (Canton), which had been the major hub of foreign trade since the Tang Dynasty in the 8th century (which it had boasted a foreign population – primarily Arab – of more than 150,000 before the rebel Huang Chao had rode in and slaughtered everyone he could find in 878… but that’s another story).
It’s also important to understand the overall Chinese worldview, as it relates to foreign relations. I’m sure I’ll not surprise anyone by telling you that the Chinese name for China, 中国 (zhongguo), means “Middle Kingdom/Country”. That’s not just a cute moniker, though, but in fact very succinctly summarizes the imperial Chinese worldview. They were, quite literally, the center of the universe. The ancient capital city of Luoyang (long in disuse by the time of the Ming and Qing, I should note), was specifically chosen because it was determined to be the precise center point of Heaven and Earth. This centrality extended well past the geographic and into the cultural and technological as well… China deemed itself to the fount from which all civilization sprang, and one of the chief markers of civility vs. barbarism was how “sinified” whichever particular group of barbarians had become. This isn’t to say that China would have necessarily called Europeans barbarians (at least not to their faces), but they did view European nations much like they did Japan, Korea, or Tibet – lesser states which pales into comparison to the majesty of the Realm – if they were feeling nice, they might reference said states as “little brothers.” And the thing of it was – they weren’t wrong. Don’t let the last couple of centuries fool you, the 19th and 20th centuries were historical anomalies in terms of world order... and certainly in terms of civilizational ranking re: China vs. the West. For the other 2000 years of the imperium, China on its worst day was at least equal to Rome on its best. Regardless, any and all missions – which were viewed as being simply trade missions by Europeans – were categorized and seen very differently by the Chinese court, namely as the customary tributes that a lesser entity would make to a hegemon. Jumping somewhat ahead to the Qing Dynasty, probably the most widely known British trade mission to China was the ill-fated Macartney Mission of 1793, in which Britain sought a permanent embassy in China, special trade rights through Canton, and rights to a small island off the coast, and the Qianlong Emperor flatly refused them everything, issuing an edict to King George III stating, “Our dynasty’s majestic virtue has penetrated unto every country under Heaven, and Kings of all nations have offered their costly tribute by land and sea. As your Ambassador can see for himself, we possess all things. I set no value on objects strange or ingenious, and have no use for your country's manufactures.”
In a followup message, Qianlong attempted to further explain and clarify his position, but the wording he chose in doing so is remarkably telling as to his own worldview (which of course was utterly at odds with Britain’s view of itself as the preeminent world power of the era (recent loss of its largest colonial holdings notwithstanding). Interestingly, the very meeting between Macartney and Qianlong had been very nearly scrapped because the British ambassador had refused to perform the ritual kowtow as was required in the imperial presence. A compromise was ultimately reached wherein Macartney was allowed to merely genuflect rather than perform he full kowtow… but it was an end-run compromise only reached a day or so before the meeting was to occur at Chengde. Anyways, here’s the followup to George III:
You, O King, from afar have yearned after the blessings of our civilization, and in your eagerness to come into touch with our converting influence have sent an Embassy across the sea bearing a memorial. I have already taken note of your respectful spirit of submission, have treated your mission with extreme favor and loaded it with gifts, besides issuing a mandate to you, O King, and honoring you at the bestowal of valuable presents. Thus has my indulgence been manifested.
Yesterday your Ambassador petitioned my Ministers to memorialize me regarding your trade with China, but his proposal is not consistent with our dynastic usage and cannot be entertained. Hitherto, all European nations, including your own country's barbarian merchants, have carried on their trade with our Celestial Empire at Canton. Such has been the procedure for many years, although our Celestial Empire possesses all things in prolific abundance and lacks no product within its own borders. There was therefore no need to import the manufactures of outside barbarians in exchange for our own produce. But as the tea, silk and porcelain which the Celestial Empire produces, are absolute necessities to European nations and to yourselves, we have permitted, as a signal mark of favor, that foreign hongs [groups of merchants] should be established at Canton, so that your wants might be supplied and your country thus participate in our beneficence. But your Ambassador has now put forward new requests which completely fail to recognize the Throne's principle to "treat strangers from afar with indulgence," and to exercise a pacifying control over barbarian tribes, the world over. Moreover, our dynasty, swaying the myriad races of the globe, extends the same benevolence towards all. Your England is not the only nation trading at Canton. If other nations, following your bad example, wrongfully importune my ear with further impossible requests, how will it be possible for me to treat them with easy indulgence? Nevertheless, I do not forget the lonely remoteness of your island, cut off from the world by intervening wastes of sea, nor do I overlook your excusable ignorance of the usages of our Celestial Empire. I have consequently commanded my Ministers to enlighten your Ambassador on the subject, and have ordered the departure of the mission. But I have doubts that, after your Envoy's return he may fail to acquaint you with my view in detail or that he may be lacking in lucidity, so that I shall now proceed [...] to issue my mandate on each question separately. In this way you will, I trust, comprehend my meaning[...].