Aud, Dutch colonists (and French Huguenots) settled there long ago.
There were Hottentots who already lived there.
And they imported slaves (African and Malay).
These people (Hottentots, blacks, French and Malays) learned Dutch and switched to Dutch. And then everyone (both whites and coloureds) spoke creolized Dutch.
Whites wrote in literary Dutch though, before 20th century - and the first books in Afrikaans were Muslim texts published for local Muslims (of Malay ancestry) in Arabic script.
In 20th century it became official language.
This doesn't explain "why" (why exactly it is not like "Whites speak Dutch and coloureds speak creolized Dutch"? "Why Khoisan languages disappeared?" "Why Hottentots themselves assimilated and now there is only mixed population?") but it is what I know about history.