The British left India because it was hard to keep and maintain. And a large deciding factor was the Naval Mutiny of 1946. And the battle brought to India through Subhash Bose with Japanese aid was also a huge factor. They just decided India couldn’t be ruled anymore.