Exodus 21:26

And if a man smite the eye of his servant, or the eye of his maid, that it perish; he shall let him go free for his eye’s sake.

The rule is part of the instruction and statutes God gave to Israel through Moses.
If a master struck the eye of his manservant or his maidservant so that it perished, he was required to let the servant go free for the eye's sake as compensation for the injury.
Even the loss of a tooth required that the injured servant be set free, and in this way the law gave servants strict protection against injury by their masters.

The law guards against injustice and guides people in how to deal with one another.
The statutes show God's care for the poor and the fairness and high moral standard of His requirements.
Israel's own memory of slavery was to lead its people to treat servants with kindness and compassion.