The Mughal Empire under Shah Jahan actually did attempt to expand past Afghanistan into Central Asia, and their motive for doing so was precisely because they considered themselves to the rightful heirs of the Timurid empire, and Timur's capital of Samarkand to be the rightful inheritance of the Mughals. The Mughal court historian Abdul Hamid Lahori writes the following in Vol. II, p.482 of his Badshahnama (all emphasis is mine):
Ever since the beginning of his [Shah Jahan's] reign, the Emperor's heart had been set upon the conquest of Balkh and Badakhshan, which were hereditary territories of his house, and were the keys to the acquisition of Samarkand, the home and capital of his great ancestor Timur Sahib-Kiran. He was more especially intent on this because Nasir Muhammad Khan had had the presumption to attack Kabul, from whence he had been driven back in disgrace. The prosecution of the Emperor's cherished enterprise had been hitherto prevented by various obstacles, but now the foundations of the authority of Nasir Muhammad were shaken, and his authority in Balkh was precarious [. . .] So the Emperor determined to send his son Murad Bakhsh with fifty thousand horse, and ten thousand musketeers, rocketmen and gunners, to effect the conquest of that country.
The "Nasir Muhammad Khan" mentioned here was the Khan of Bukhara (in modern-day Uzbekistan) between 1642 and 1645, and he belonged to the Janid dynasty. He had attempted an attack on the Mughal provincial capital of Kabul in Afghanistan, but was repulsed. Moreover, Nasir Muhammad Khan faced civil war at home, and in April 1645 was overthrown by his son, Abdul Aziz Khan. It was during this time that Shah Jahan decided to launch an attack against Bukhara, since he assumed that the Janids were in a state of confusion and would be unable to effectively resist the Mughals.
In August 1645, the Mughals began their opening moves by sending an army north to Badakhshan (what is now northeastern Afghanistan and eastern Tajikistan) under the command of Asalat Khan. Two months later, in October 1645, Shah Jahan dispatched the Rajput general Raja Jagat Singh from Kabul to strengthen the Mughal defenses in northern Afghanistan, in anticipation of a counterattack from Bukhara. A Rajput garrison was established between the Sarab and Andarab rivers, in what is now the Baghlan province. Raja Jagat Singh returned to Kabul by 4 November, having completed his task.
The main Mughal offensive took place in the following campaigning season in June 1646, when Shah Jahan sent his son Murad Bakhsh to capture and fortify Balkh. Murad Bakhsh marched with a large army of 50,000 cavalry and 10,000 infantry, as described by Lahori. He arrived at Balkh on 2 July, and secured the city. As far as we know, Murad Bakhsh did not face any major resistance during his operation. However, Murad Bakhsh did not approve of his father's desire to conquer Central Asia; he regarded this to be a foolish and wasteful venture, and wished to return to India. Many of Murad Bakhsh's subordinates agreed. In the Badshahnama, Lahori writes the following:
Many of the amirs and mansabdars, who were with the prince, concurred with this unreasonable desire [to leave Balkh]. Natural love of home, a preference for the people and manners of Hindustan, and the rigours of the climate, all conduced to this desire.
With the Mughal commanders thus indifferent to the campaign, and preferring to serve in Hindustan (North India) rather than in cold, poor, and distant Central Asia, many of them began abandoning their posts and forsaking their duties. Shah Jahan was understandably furious when he learned about this, and immediately sent his vizier Sadullah Khan to take the place of Murad Bakhsh. The former arrived at Balkh by August 10, while the latter was disgraced and stripped of his mansab (rank). Shah Jahan himself also personally moved to Kabul to oversee and direct the campaign. As winter approached, the Mughals hurriedly garrisoned key outposts between northern Afghanistan and southern Central Asia, including Termez, Qunduz, Rostaq, Taleqan, and Maimana. However, by this time bands of Bukharan light cavalry had begun infiltrating into the Mughal territory and pillaging the countryside, leaving Balkh in a state of siege during the winter of 1646-47. The Mughals at this point were stuck, and could not advance deeper into Central Asia.
In the following campaigning season, Shah Jahan appointed Prince Aurangzeb, then serving as subahdar (governor) of Gujarat, to lead operations into Central Asia. Aurangzeb arrived in Kabul on 3 April 1647. Four days later, on 7 April, he set out for Balkh to reinforce the Mughal forward positions and extend the campaign, and successfully reached Balkh by 25 May, placing it under the custody of Rajput general Madhu Singh Hada. Aurangzeb had 35,000 men under his command, with the bulk being heavy cavalry, and with musketry and artillery regiments for support. In contrast, his Bukharan opponents generally lacked heavy gunpowder weaponry, but they possessed a more mobile force consisting almost entirely of light cavalry.
From a purely tactical perspective, the Mughal army under Aurangzeb did not perform poorly at all. A case in point would be in a battle fought on 21 May 1647, when the Bukharan cavalry under the command of Qutlugh Muhammad launched a frontal assault against the Mughal army, and was repulsed by musket fire. The Mughal cavalry then capitalized on the disarray in the enemy ranks by enveloping and destroying the enemy force. Similarly, in an encounter on 2 June 1647 near Aqcha, the Bukharan forces under Beg Ughli were repulsed by the musket fire of the Mughal vanguard under the command of Bahadur Khan. However, despite these tactical victories, the Mughals did not make any strategic gains. Although the Bukharans never routed any Mughal army, they succeeded in disrupting their supply lines, wearing them down through endless skirmishing, and leaving the Mughals in a state of desperation. On 5 June, Aurangzeb received news of another army sent from Bukhara to attack Balkh, which was the key Mughal supply center. Unlike in India, where the Mughals could always rely on banjaras (grain merchants) having plenty of food available for sale, in distant Central Asia no such security existed. The Mughals had to transport all of their food with them, and if Balkh fell, so too did the ability of the Mughal army to function independently. Thus, Aurangzeb was forced to return to that city. Two days later, on 7 June, the Bukharans under the command of Subhan Quli Khan (the brother of Abdul Aziz Khan) launched one final attack on the Mughal army, with the full force of the Bukhara cavalry. Just like in the previous military encounters, the Bukharans were ultimately repulsed by the Mughal musket and artillery fire, but not before inflicting serious losses on the Mughals and their logistical supply line.
Aurangzeb returned to Balkh by 11 June, and decided to put an end to the campaign. The financial situation was terrible, with massive inflation in food prices due to plundering and losses. A single maund (about 55 lbs.) of grain was being sold for ten rupees to the Mughal army, while the usual price in Mughal India was about 185 lbs. of grain for a single rupee. The Mughals also lost over 5,000 pack animals due to the cold weather and enemy raids. The total financial cost of the campaign came to 4 crore (40 million) rupees, while the Mughal army was only able to collect 22 lakhs (2.2 million) rupees from revenue and plunder over the course of their campaign. To make matters worse, Aurangzeb was also facing dissensions among his commanders like Bahadur Khan, who - like Murad Bakhsh and his subordinates earlier - had a strong desire to return to India and pursue their careers there, rather than in Central Asia. Thus, Aurangzeb opened up negotiations with the grandsons of Nasir Muhammad Khan, and handed over the city of Balkh to them on 1 October.
This was the first and only time that the Mughals attempted to expand beyond the "natural" boundaries of their Indian empire, into their ancestral homeland in Central Asia. It was a sufficiently a disaster that no subsequent Mughal regime attempted this. When Aurangzeb himself became emperor, succeeded his father Shah Jahan, he dedicated his energy to further conquests in the southern portion of the Indian subcontinent, rather than in Afghanistan and Central Asia. Economic factors, combined with cultural and climactic factors, made campaigning in the former much more preferable to campaigning in the latter.