At school, a teacher mentioned that the "slave trade saved Africa from its own barbarism." This seems ironic considering the slave trade. Is there any truth to her words?
Historians don't use words like "barbarism" with a straight face. Ever. Well, ok, we sometimes use it when talking about the historical views of people who did not understand that cultural difference =/= inferiority, or (maybe) to describe acts of extreme brutality, but we have long since moved past the notion that whole cultures (much less whole continents) are "barbaric."
It sounds like your teacher is applying a teleological view of human cultural development that hasn't been seriously used by academics in a very long time (like, for more than 100 years). In fact, I would go so far as to say that the argument that the slave trade "saved" Africa from anything is inherently racist - the implication there is that as bad as the slave trade was (and we know that it was really, really bad) that Africa and Africans (as if we can talk about these people as a single group) were somehow worse off when left to their own devices. It's a patently ridiculous argument.
You'd probably have to ask your teacher what they meant.
However, the slave trade was common across Africa, the Mediterranean, and the Middle East, though it was dramatically different from slavery in the Americas. This has been addressed by many other threads on the forum; depending on what you are interested in, search for the "Barbary Slave Trade" (not related to Barbarism, it refers to North African states, which often enslaved Europeans from coastal communities in Southern Europe and elsewhere), "Muslim slave trade", "Arab slave trade", "African slave trade", and so on.
Africa is a big place; many slaves in the Americas came from West African states, which has a history of large, well-organized empires, such as Mali. Indeed, the fact that West African states were relatively powerful helped drive the Atlantic slave trade, as West African slave traders developed sophisticated, demand-driven slave trading networks that reached into the African interior. This topic has also been extensively addressed.
However, elsewhere in Africa slavery by Arabs or North African traders would have been far more likely and more common.
Throughout Africa, though, calling it "barbaric" would be a tough sell. In North and West Africa, two of the areas most heavily impacted by the slave trade, there is a long history of powerful empires and other states. Arguing that the slave trade saved anyone from "barbarism" would be a tough sell, unless you really twisted his/her words. However, the statement in itself is way too broad (Africa is huge, what does s/he mean by "saved" or "barbarism") to categorically state there is no truth whatsoever to it.... though I would venture to say that no, there is not likely to be much truth to it. There were well-organized polities in much of Africa (Zulu in South Africa, Ethiopia in East Africa, the West African empires and other states, Berbers in North Africa, Arab states in Northeast Africa), and calling it "barbarism" is not going to fly well with most scholars of African history. Even in the most under-developed areas, that were mostly tribal, saying that the slave trade "saved" them is not supported by the evidence. It devastated regions not just by the trade itself, but by wars to control the slave trade. How that "saved" any part of Africa is something your teacher would need to explain. You might be able to argue that colonialism helped advance economic development in some regions (South Africa), but the slave trade? I'm leaning heavily towards "no, there is no truth", but it's a very broad and very vague statement, so there's a .001% chance there might be some isolated case somewhere that gives it a grain of truth.
In addition to the comments above, I would add that there is an active debate within African history over how much the slave trade contributed to long-term political and economic difficulties in the regions where it was prominent (through mechanisms such as depopulation and incentives for states to develop more authoritarian forms of rule). The claim your teacher made, by contrast, is not considered defensible by any Africanists that I am aware of. In fact, it's so far removed from the conclusions of experts in the field, and so reminiscent of claims that were used to justify slavery in the Americas, that I would be calling up the teacher to have a chat if my own daughter came home from school having been told this. I don't want to insinuate anything negative about your teacher, who may have learned this idea in good faith during her own education, just trying to convey how completely off base this idea is currently considered.