Many Indian nationalists embraced Hinduism from the 19th century onwards as a unifying identity that was commensurate with Christianity, the religion of the European colonials. 
In the Indian independence struggle, Mahatma Gandhi popularized Hindu concepts like ahimsa (non-violence) as tools for countering colonialism. Gandhi himself envisioned a secular state (not a religious state, and not favoring any one religion) that was nonetheless guided by spiritual principles.
Thus, defining themselves by way of Hinduism enabled many Indians to speak of themselves as peers of Europeans with a proud tradition of their own, rather than as servants. Hence they were justified in seeking to govern themselves.