There are multiple reasons.
India had been accusing Pakistan of state-sponsored terrorism since 1980s but the world was not taking it seriously and was instead treating both countries equally. But that all changed after 9/11 incident after which it became increasingly difficult for the Islamic Republic of Pakistan to get away with terrorism as many countries started pointing fingers at it.
So, ironically, they thought the best idea to combat this is if they can show that India also does terrorism thus levelling the playing field.
To do that, they send 10 terrorists to Mumbai at night secretly by hijacking a local fishing boat. These 10 terrorists were to die as Indian Hindus. They had fake ID cards in the Indian Names in their pockets. They even wore sacred hand bands worn by religious Hindus. [source]
So, the idea was to make it look like an Indian-Hindu Terrorist attack [source] where Hindus are attacking rich foreigners in five star hotels, thus creating a bad name for India. They had thought once these 10 terrorists die in Mumbai, and the bodies will show evidence that they were Hindus, thus no connection to Pakistan at all.
Their plans got foiled because one terrorist was caught alive albeit with great sacrifice. One unarmed Police officer named Tukaram Omble jumped and grabbed one terrorist's Ak-47 pointed towards him. He got shot 40 times at point-blank range but he kept holding the gun. He died immediately but this helped other policemen who were also unarmed to catch this heavily armed terrorist alive. [This cop was awarded India's highest gallantry award]
This terrorist later confessed everything and gave out a lot of details(you can see it in this documentary). Apart from that, later the Indian intelligence was able to track and record the conversation between the terrorists and their handlers in Pakistan.(again watch the documentary to hear it)
The secondary objective was to initiate a Hindu-Muslim civil war within India thus destabilize the country.
With tertiary objectives probably being to defame the country and thus reduce foreigners from going there and reducing investments in India. Pakistan was getting zero investment from foreign companies at that time due to terrorism and instability while India was getting plenty, so they probably wanted to stop that by attacking the financial capital of India.
BUT, the biggest objective is to stop India and Pakistan from becoming friends. This is because Pakistan is a military dictatorship with a puppet civilian government. When there are no issues, India often shows a hand of friendship and the Pak civilian government sometimes supports it. The dictator cannot afford a friendship between India and Pakistan as that would render the military irrelevant and thus they lose power.
So, whenever India and Pakistan gets too friendly, you can be sure that a terrorist strike is about to happen as that will destroy that relation. These kinda terrorist strikes have happened every time they both got friendly, and this time also, they were getting close. Just for examples
After all these, message was clear for India that getting friendly to Pakistan means a terrorist attack and the current Indian Government official policy is to not do dialogue with Pakistan as it is futile, as real power is with the Army dictatorship. Peace is only possible if this dictatorship is broken. I wish if the Pakistani public get the courage and start a massive revolution and solve this problem for once and all.
- 1999 - Indian pm travelled to Pak crossing border in a public bus and was welcomed by pak PM. They both were acting like buddies and friendship was assured. Then Kargil happened. When Indian PM called Pak PM on phone to discuss this backstabbing, he was not even aware that PAK soldiers had attacked India and captured few mountain ranges.
- 2001 - Again India and pak got too close and then 2001 Indian Parliament attackhappened.
- 2008 - India Amen ki Asha project. Both getting too close. Then this mumbai 26/11 happened.
- 2016 - India Pak was getting too friendly. Indian PM Modi event went to Pakistan PM's daughter's wedding. Within two weeks Pathankot terrorist attack happened.