The thing is that Rowling hadn’t really thought it through yet. Having the hero save a slave is pretty clearly heroic and good, and it’s a nice way to wrap up the Dobby story arc, but then the fans were all like “wait WHAT!? there’s slaves under Hogwarts!?” and she was forced to think it through, and it turns out JK’s pretty awful so the result of her thinking it through was to make it worse.
That happens in the books too. He only does it because the slave owner is a mean slave owner, though, not because slavery is wrong.
The thing is that Rowling hadn’t really thought it through yet. Having the hero save a slave is pretty clearly heroic and good, and it’s a nice way to wrap up the Dobby story arc, but then the fans were all like “wait WHAT!? there’s slaves under Hogwarts!?” and she was forced to think it through, and it turns out JK’s pretty awful so the result of her thinking it through was to make it worse.