During the British rule, there were so many princely states. After independence, most of them joined India and few handful joined Pakistan. Jammu & Kashmir was the only princely state that decided to remain independent after 1947.
Kashmir was independent until the October of 1947 when Pakistan decided to forcefully annex it. The invading army took a big chunk of the state and plunged the state into darkness by cutting the power supply hence starting the Kabali (Pashtun tribal) war against Jammu and Kashmir.
Once these tribes cross the border and reached the Jammu and Kashmir, Maharaja asked for India assistance. After that the monarch of Kashmir, Hari Singh invited India to save the country hence signing the instrument of accession.
Meanwhile, Pakistani Pashtun tribes reached Jammu and Kashmir and started raping, looting Muslim population. Indian army entered the state and got rid of the invading group from two-thirds of the state.
Three years later, elections were held in Jammu & Kashmir and people of J&K voted in favor of joining India formally. The constituent assembly of Jammu and Kashmir – A Constitution was written by the Kashmiris and that explicitly said that the state would be a part of the Indian Union.
Since then, multiple elections have taken place as a part of Indian democracy and the people showed the little intent of leaving India.
India and Pakistan fought 4 major wars and each time Pakistan believed that the people would rise up against India & welcome the invading forces. Each time, the locals rose up against the invading forces and always tipped the Indian army. What the locals want is peace and the ability to run their own life. They want Pakistan to leave them alone and want their own government to reduce the armed presence created as a reaction to the neighbor’s advancements.
Legally the state of Jammu & Kashmir is a part of India – through the monarch’s instrument of accession and morally it is a part of India as most people have voted for it. There should end the story. Other than a few miscreants both in India and outside, people feel they are a part of India.
What Pakistan did by war violence and military procrastination for 65 years, India did by political procrastination (for ~40 years) and illegally hard state-sanctioned militarization (for ~20 years).
Even if an independent state of J&K would be left alone, the powers around it would soon invade it. Besides the Muslim population, the state also has a large Hindu and Buddhist population. In the case of an occupation by Pakistan, those populations would be decimated – similar to what happened in Sindh and Pakistani Punjab in 1947. The whole-scale extermination of people is completely unacceptable.
In short, India has a strong moral ground and both Kashmiris and the rest of India find it comfortable with the present status quo. It is also fairly clear from our past experience that India leaving the state would cause more harm to the locals [especially Hindus and Buddhists and to some extent the Kashmiri Muslims as well] than India managing it.
So, however Pakistan may try claiming Kashmir, it is formally a part of India and will always be.