A few reasons come to mind (and I'll direct you to Tlou's History of Botswana although I'm not sure he's quite as forthright about it). Politically, Botswana was a protectorate, not a true colony; it was based on artificially-drawn boundaries, but the consent came from an actual leadership, one headed by the Ngwato kings. An effort to hand its control over to private settlement and exploitation company interests, namely the British S. A. Company of Cecil Rhodes and others, failed when King Khama III went to London to plead the case of "Bechuanaland" before the British government, on the grounds that this was a breach of the terms of the protectorate. The imperial government agreed, and Botswana remained a protectorate of one flavor or another until independence. The result is that it's been largely English and seTswana speaking, originated from a single majority political order, and always had some sort of assent to the forms of British rule. It doesn't have the internal fractiousness of other postcolonial states, though admittedly it does not have quite their population either (about 4.5 million, IIRC). Many in the ruling classes took advantage of the education missionaries offered, too, so a significant new elite of baTswana arose in the Protectorate in the 20th century and pushed for parliamentary government.
The other reason Botswana's done well compared to similar sorts of protectorates (Lesotho and Swaziland come to mind) is that the biggest strikes of mineral wealth came after independence. In that situation, Botswana could marshal its control of those resources to negotiate fair partnerships with extractive industries and plow some of that wealth back into the country. It's not exactly a first world lifestyle, but it's stable and the economy continues to grow. The discontent among the population are relatively less of a worry for the government as a result. They've engaged in some questionable actions regarding squelching free speech, and the oligopoly of certain notable families is an issue, but overall it's been doing all right.
Botswana's not quite the only African state to enjoy a relatively stable postcolonial existence, but it's probably been the most consistent.