Muhammad Ghori left for Ghazni because that was the capital of his already existing kingdom. He did not come to India to establish a new kingdom. Instead, he wanted to conquer India to add to his already existing kingdom. Once that was done, he left India leaving it in charge of a governor.