What made them unjust? They were made by elected officials at the time.
As opposed to conseqentialism, in this view, if the laws are made in accordance with agreed and lawful procedure, they are just.
Most people skew towards consequentialism, but not all.
1. https://pediaa.com/what-is-the-difference-between-deontology...
This isn't exclusive to laws though anyhow. If you believe morality can be better tomorrow than today then you have to accept either being immoral today or only relatively moral to your own time.
In fact, why do we even change laws? We must aim to only make new non-overlapping laws preserving the integrity of our previous ones.