The caves are a legacy of Dunhuang 's emergence more than 2,000 years ago during the Han Dynasty as a crucial entranceway into China by the Silk Road , which served as the principal trade route to the West .