Lesotho: The country Inside South Africa

Lesotho is a country inside of a country. It is an enclave and the largest in the world at that. How did the country of Lesotho come to be? Why is Maseru it's capital and why is it not a part of South Africa?