Well come on who has read and remembers every verse of the bible at 17 years old!
Because back then slavery was kind of like being a servant or a worker, they gave you food and shelter for your labor....
God hasnt shown lack of moraility, we just dont understand it perfectly.