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.
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.