The first foreign invasion was of course the Aryans. Later you had the invasion of Alexander the Great. The muslim invaders mentioned above were able to integrate themselves over time into Indian culture and like the Aryans became an integral part of Indian society. India not only has the spices, minerals and textiles mentioned above, but great fertile river valleys. It's agricultural potential and riches were also part of the lure to invaders. As India became one of the centers of human population and civilization from very ancient times, the human resources of the subcontinent were also exploited by foreign invaders.
The decline of the Mughal empire coincided with the global expansion of Europeans such as the Dutch, Portuguese, French and most importantly the British. They represented a different kind of exploitation along a European colonial model, more interested in imposing European cultural traditions rather than integrating into Indian society as in earlier invaders. The Indian sub-continent (Now Pakistan, India and Bangladesh) is a vast geographic area, which very early became part of the East-West trade routes (particularly sea routes) and Empires tended to expand along such routes.
Invasions by the Arabs and the Turks marked the medieval history of India. A number of factors were responsible for the incursion of the foreign forces. During the medieval period, India was politically divided into many states which constantly fought against each other. Socially, the caste-system existed but it had not grown rigid. Muhammad - Bin- Qasim attacked Sindh in 711 A.D. The meagre monetary resources of Sindh, its military weakness and sharp social divisions, the indifference of other Indian rulers towards the fate of Sindh, the pre-eminence of arms and military tactics of the Arabs and the incompetence of Dahar were the main reasons of the success of the Arabs. The Turks invaded India in the eleventh and twelfth century. The Turks are given credit in establishing the Muslim rule in India. Sultan Mahmud of Ghazni was the first ruler who was successful in breaking up the military strength of the Hindus and plundering the wealth of India. Political weakness was one of the causes of the defeat of the Indians. After emperor Ashoka, India could not be united under one rule.. The most important cause of the weakness of India was that Rajput states were engaged in constant fighting against each other for power and glory and failed to unite themselves against a common enemy even in the greatest hour of danger to their country, its culture and religion.
Foreign invaders invaded India for spices, minerals and textile. This could bring an improvement in their trade. While, Muslims conquered sub continent to spread Islam. When Muhammad Bin Qasim came to sub continent, he defeated the ruler and spreaded Islam.