I believe your question refers to the World Economic Formum rankings. As the government and Mail & Guardian noted in their responses, the WEF rankings are based on outside perception, not student achievement. Nevertheless, student achievement makes it clear that South Africa has among the worst education systems in the world. Although the matric pass rate for mathematics has increased recently, some have argued that the standard has decreased. The most frequently quoted stat is that the 2013 grade 9 maths average on the Annual National Assessment (ANA) was only 14%. Unfortunately, South Africa has not participated in PISA for many years, but the TIMS indicates that South Africa's grade 9's scored next to last out of forty two countries, despite the fact that in nearly all other countries the test was given to grade 8 students!
To understand South Africa's education problem it's important to go back and acknowledge that South Africa has made significant progress since the end of Apartheid. Under Bantu education, for example, black South Africans were denied any meaningful amount of mathematics education. H.F. Verwoerd famously said (back in 1953):
There is no place for [the Bantu] in the European community above the level of certain forms of labour ... What is the use of teaching the Bantu child mathematics when it cannot use it in practice?
It's difficult to quantify the lingering effect of Bantu education now that today's students were all born after the end of apartheid in 1994, but I'd say offhand that South African maths education is recovering from Bantu education.
It is very clear that since 1994, South Africa's education system has been well funded. For example, in 2007, South Africa spent USD 1 225 per pupil, whereas Kenya (with higher maths and reading scores) spent only USD 258. Though there have been complaints about corruption (such as the Limpopo textbook fiasco ) and wastefulness, but 60% of South Africa's schools are free, and this percent is growing. South Africa's 250 000 teachers are paid reasonably well, especially considering South Africa's very high unemployment rate and low cost of living.
Now, here are some suggestions as to how South African mathematics education can improve:
1) Give teachers better training. In a test of maths teachers' content knowledge, a researcher from the University of Stellenbosch found that 5% of grade 6 pupils at disadvantaged schools know more than 20% of their teachers. The same report goes on to say that only 32% of grade 6 teachers have adequate content knowledge. Jonathan Jansen has made a compelling argument that teachers - rather than students - should write comprehensive national tests to see if they are fit for teaching. The department of education has made some effort to train teachers the recent adoption of the CAPS curriculum, and more training should be done.
Before I move on to other suggestions, I must note that this is probably the most practical thing you and I can do to improve mathematics education in South Africa. I can't think of any practical way I can solve issues 2 and 3 without becoming high up in government or education, but there are many ways to promote better maths teaching. As a second-year maths teacher outside of Pietermaritzburg, I'm currently in charge of an outreach programme at a disadvantaged school where my high school students teach maths and reading to primary school students. Another teacher in my department spends much of her assisting other maths teachers by doing demonstration lessons, teaching teachers, and supporting teachers who want to improve their results. I know of others who are encouraging schools to adopt technology and helping teachers use computer labs effectively. Others are gifted at networking between schools, fundraising, running after school programmes, etc. Anyone (including those who dislike maths) can be involved in this important work.
2) Improve relations between the teachers union (SADTU) and the department of education. Recently in KZN, SADTU has complained about low and missing teacher pay, while reports have surfaced that principal positions have been sold for R30 000. In all this, the SADTU president was recently expelled. Whatever side one takes, it's very clear that there is a lot of labor unrest in South Africa. The story of principal positions being sold is especially disheartening considering the vital role principals play in developing good teachers and removing incompetent ones.
3) Increase standards. Though the department of education has proudly announced that matric results are improving, there's little doubt that the standard of maths education has declined in recent years, especially for students taking maths literacy or receiving receive a 30% "pass". This report sums up the main criticisms well, including a high dropout rate, low pass rate, easier subjects, and high variance.