Why South Africa is the richest in Africa?

South Africa has leaders who want to help there country, whereas others, like Mugabe, are corrupt and some, like Quadafi, are tyrants.