This is a complicated issue, and I don't know a lot about it, but the outlines are in Wikipedia's article on the Government of India Act 1935
Indians had increasingly been demanding a greater role in the government of their country since the late 19th century. The Indian contribution to the British war effort during the First World War meant that even the more conservative elements in the British political establishment felt the necessity of constitutional change, resulting in the Government of India Act 1919. That Act introduced a novel system of government known as provincial "diarchy", i.e., certain areas of government (such as education) were placed in the hands of ministers responsible to the provincial legislature, while others (such as public order and finance) were retained in the hands of officials responsible to the British-appointed provincial Governor. While the Act was a reflection of the demand for a greater role in government by Indians, it was also very much a reflection of British fears about what that role might mean in practice for India (and of course for British interests there).
The experiment with dyarchy proved unsatisfactory. A particular frustration for Indian politicians was that even for those areas over which they had gained nominal control, the "purse strings" were still in the hands of British officialdom.
The Indian National Congress continued to push for reform and independence, and after many protests, Gandhi travelled to London to take part in the Round Table conferences.
After much more deliberation and argument, the 1937 act was passed by the UK Parliament. It created representative governments in the individual Provinces of British India, which were elected in 1937. BG Ker and C. Rajagopalachariwas were ministers in those governments, which ruled parts of India. The intention was that the "princely states" of India would join the Provinces in a Federation of India, but not enough of them were willing to do so before the outbreak of WWII put the whole issue on hold.
After WWII, the British were loosing control of India, and made it independent as quickly as could be arranged, which wasn't very fast.