The struggle for equal and quality education was "indistinguishable from the struggle for freedom", he told students.
South Africa has dramatically increased the number of children in school since apartheid ended more than 20 years ago.
But just under half of students will complete high school and many poor black children are still being left behind because of the quality of teaching and a lack of good facilities, equipment and text books at their schools.
Education is the best way to end the inequality, the country's President Cyril Ramaphosa has said.
“It is through education that we can realise the goal of a non-racial, non-sexist and democratic society,” he told a graduation ceremony.
“It is through education that we can give full expression to the rights enshrined in our constitution. Our society still bears the scars of its divided past."
His words echoed the findings of a report by the Centre for Risk Analysis (CRA) at the Institute of Race Relations (IRR) last month. It said South Africa's deficient education system is the single greatest obstacle to socio-economic advancement.
President Ramaphosa's comments were made at the University of Mpumalanga in Mbombela, where he is the Chancellor. He added: “In education, we are still grappling with the legacy of a deeply unequal and racially divided system.
"From the beginning of the 20th century, the struggle of our people for equal and quality education was indistinguishable from the struggle for freedom.”
A historic moment in that struggle came in 1976, when a peaceful march by schoolchildren in the Johannesburg township of Soweto ended in tragedy when the police began shooting.
There are various reports of how many people died - 176 is the figure usually given but some estimates put the toll at 700.
A picture of dying schoolboy Hector Pieterson being carried away became a symbol of the Soweto uprising and helped to mobilise international opinion against apartheid. The photographer who took it, Sam Nzima, died on May 12 aged 83.
Access to quality education is also an issue for South Africa's 3.7 million orphans - half of whom lost their parents to AIDS-related diseases.
The South African comedian and TV presenter Trevor Noah is doing his bit to help some of those orphans.
Asked about the recent launch of the Trevor Noah Foundation, he said: “That comes off of my love for education, teachers and giving kids an opportunity."
Appearing on The Late Show on US TV, he added: “My dream was to help grow education in South Africa. During apartheid black people weren’t given access to education but my mother still found a way to teach herself.
"Because of her I got a chance to learn in good schools and because of that every generation of my family will get better. Education is the stepping stone that gets people to the next level.”
The foundation has started by helping the New National School in Johannesburg.
Noah - who presents The Daily Show on Comedy Central - said: “These kids have nothing - they maybe only have one meal a day. But they are learning as hard as every other kid. They’re proud of what they do, they’re proud of who they are.
“I thought if they can do this with nothing, imagine what they can do with just a little bit more.”