Since your question asks us to concern ourselves specifically with the Middle Ages (5th to the 15th century), I will not venture to comment on the Mughal Dynasty and the shaping of identities in the modern world. However, to ground all of this in present-day observable context, I'd like you to give this a read.
Islam's contact with India can be traced back to the 7th century. For the time-period being observed, and throughout all of history, Islam has come to India through the following two pathways:
- Sea route i.e Arabian Sea
- The North-West Corridor of India
Before the Islamic conquests began in earnest with the Raja of Sindh's battle against Muhammad bin Quasim, the Eastern Hemisphere looked something like this:
India appears pretty fragmented at this point. This is because much of her political history has been that of chiefdoms gaining excessive power and breaking away from their kingdoms. There was also great hostility between them.
India, in its modern form, would emerge only in the 13th century, under the Delhi Sultanate. Before that would happen, Muslims were indeed looked at with leeriness by the Hindu population. The Central Asian traveller Al-Biruni attributed it to the fact that the Arabs had, in their conquests, taken several Indians as hostages and there was a general climate of mistrust prevalent among the people.
This wasn't all unsound though, considering that Mahmud of Ghazni and his commanders had plundered and laid waste several Hindu temples that had once boasted great riches.
In 1206, with the coming onto the throne of the Mamluk Dynasty, former kingdoms that were now annexed and under Muslim control, for the first time came under a centralised force. Up until the end of the Medieval Era, Hindus in India easily outnumbered the Muslims. Very early on, it was realised by the Muslim rulers that force wouldn't get them very far.
This is what the Delhi Sultanate looked like at its apex:
Being a highly feudal state, the rulers had no other option but to incorporate Hindus into the administrative system, in light of the fact that most of the land was owned by them. Hindus also had exclusive control over several markets. Also being a theocracy governed by Quranic injunctions, the rulers took it upon themselves to try and bring Islam to as many people as possible and allow people freedom of religion. The kings felt that doing so was executing the will of God. This is why many Islamic holy places (to this day, I believe), guarantee free passage and protection to people of all faiths. Seeing how good a system of checks-and-balances they had established, they had no reason to worry about any province gaining too much power.
Around this time, movements like Sufism also gained ground and Islam as a religion became much more appealing to Hindus, especially those of the lower-castes who were stuck in an establishment that did not permit social mobility.
Another reason why I think there were so few spars between the two religions is because religion isn't the dominant cultural identifier for Hindus. They view themselves of a particular ethnic group and/or region first and foremost.
While it is true that conversion to Islam in India wasn't usually forced, it was almost always implied, as evidenced by this page on Islamic taxes. The rest of the picture isn't as clearly formed either. Many rulers destroyed Hindu temples to provide for materials needed to build mosques and other Islamic sites. Moreover, the frequent change of central power meant that the attitude towards Hindus always remained in a flux, and varied from one emperor to the other.
However, all in all, Islam and Hinduism shared a quite unparalleled cultural bonding in the Middle Ages, the effects of which can be felt to this day.