South Africa is courting investment from Elon Musk after he accused the government of his birth country of racist laws.