For almost as long as slavery has existed, there have been books opposing it. Perhaps the first was The Golden Ass, written in the Second Century A.D., whose plot follows a man turned into an ass, who can only turn back into a human when he empathizes with the plight of slaves.
Then there is the great American tradition of anti-slavery books by authors like Harriet Beecher Stowe, William Lloyd Garrison, and Frederick Douglass.
But as Universidad Francisco Marroquin Professor Eric Graf explains the new Learn Liberty video below, the first anti race-based slavery book was Don Quixote. 
Graf explains that the anti-slavery themes in the book stem from its author’s experience as a galley slave in Algiers and then his living in slave-based Spain upon his return. Don Quixote and his sidekick, Sancho Panza, go to equatorial Africa to liberate a population from a giant. But Sancho hopes to sell them into slavery rather than liberate them, which conflicts with Don Quixote’s vision.
Graf explains how this plot is a critique of the slave trade. It’s just another way Don Quixote is one of the greatest pro-liberty books of all time.