Over time, I've come to believe that the correct explanation is essentially our population size (which was a big deal throughout medieval times) and multifarious ethnic divisions within that population size. Each division had it's own customs&traditions it was proud of, and had ferocious, war-like people willing to die to protect their traditions. (Read this account for an overview of one such period :- https://targigradearchive.wordpress.com/2018/07/21/life-in-odisha-during-mughal-rule/)
There are numerous examples — like Rome -- of nomadic barbarians overrunning and replacing the ethnic populace of entire civilizations that were declining due to lowering fertility rates and increased pacifism. This does not seem to be the case with India or China.
Our huge population size and multiple divisions provided the impetus to renew or sustain the civilizations -- albeit in new different forms. That is, the population was huge enough to go through entire decline period(s) without fully being replaced.
Never underestimate the quality inherent in quantity!