Sumit Ganguly:

This is an issue that wasn't resolved at the time when the British were withdrawing from the subcontinent in 1947.

And both India and Pakistan laid claim to this border state which abuts both the two countries. India wanted to claim Kashmir because it's a Muslim-majority region and wanted to demonstrate that a significant minority could thrive within a predominantly Hindu country.

Pakistan, by the same token, which had been created as a homeland for the Muslims of South Asia, felt that an adjoining region had to be part of Pakistan, and otherwise Pakistan would be incomplete.

And it's this sense of incompleteness that has driven Pakistani policy and helped drive Pakistan's claim to Kashmir. But since India controls two-thirds of the state, which is what it managed to hold after Pakistan launched an invasion shortly after the British departure, that it refuses to concede ground, and Pakistan holds on to the one-third that it does, there have been multiple wars trying to resolve this issue, and a series of negotiations, but they have all ultimately run aground.