"The richest country in the 17th century" is a misnomer. Except possibly for a time after the Qing conquest, China was the biggest country in terms of population, and until the 19th century had the largest GDP, but there is no evidence for per capita income surpassing or even matching Europe's front-runners.
Approaching the question in terms of (even relative) Chinese decline is also potentially misleading. China didn't regress in absolute terms except to a limited extent in the 19th century under the impact of western manufactures and internal disarray; rather other countries experienced unprecedented growth sustained by expanding global commerce, domestic social transformation and technological advance that China was reluctant or otherwise unmotivated or poorly-placed to embrace. It was Europe's leaders and their overseas settlements that went from being modestly rich countries to (in the terms of the period) exceptionally rich ones.
There really isn’t any firm basis for a 17th-century Chinese per capita income, not least because the size of the population is unknown with any degree of certainty, while a large component of the more considered GDP estimates – the cultivated acreage underlying estimates of crop production worth nearly half of economic output – takes the form of aggregates rather than per capita indices. For 1661, when we have an Imperial return indicating perhaps 45-48 million hectares of cropland, estimates of population range from an implausibly low 53m (Deng) to 150m (Perkins). Dividing a more-or-less known by an unknown just yields an unknown. That isn’t to say that China wasn’t the world leader at some time in the past – the Song period (c.1100) is a strong candidate – but earlier income estimates are even more hazardous than for the first Qing century. And some areas did enjoy an income comfortably above the world average: the lower Yangzi Jiangnan region (southern Jiangsu and northern Zhejiang provinces) is the classic case, though it was an economic outlier with only 9% of the Empire’s population.
So the question should be, "Why didn’t China keep up?” Hypotheses range from resource constraints and lack of new agricultural or raw material sources of supply (Pomeranz) to an equilibrium trap in which population growth and labour-intensive agriculture precluded a surplus sufficient to kickstart qualitative growth, raise earnings and stimulate labour-saving (and productivity-raising) technological innovation. But that too may be the wrong question: China wasn’t a failure, but by 1800 supported more than a third of the human race, something no other polity has accomplished. Others followed a different trajectory.
______
The book that triggered the present debate is of course Ken Pomeranz’s Jiangnan-centric and flawed The Great Divergence: even its author has since backpedalled on some of his rosy imaginings of Qing potential for economic take-off. Recent reconstructions of long-run Chinese GDP owe much to Angus Maddison, Chinese economic performance in the long run, a useful survey let down by cavalier translation of qualitative impressions into spurious data. Dwight Perkins, Agricultural development in China remains invaluable after half a century for its realistic assessment of the sector that ultimately constrained the Empire’s capacity for growth.