As usual, the answer is complex.
First, at the start of the war, India was a British possession. Independence, non-violence and civil disobedience were in the political air through the 1930s, and were making progress.
Simultaneously, the Japanese ambition to form an Asian empire under the name "Co-prosperity region" had been policy through the 1930s and included invading Korea, China, Manchuria, and much of South-East Asia and, from the start of WW2, the Dutch East Indies (especially as a source of oil). It also included ambitions against India, and when (British) Burma had been conquered, from there in 1944 the Japanese staged an invasion of India through the north-eastern state of Manipur, leading to the battle of Imphal, which was won by the Indian army, under British command.
So while WW2 was on, India had a live interest in the outcome, and of the two evils, the British were clearly the lesser.
At a more general level, if you served in the British army, you got paid; and for many Indian people that mattered,
Once the war was over, India quickly won independence, starting 1947. In retrospect, the importance of the British was turning what had been numerous disparate countries into two large and fairly coherent nations, India and Pakistan. And teaching them both cricket, of course.