“according to the time-period of a hired servant is it to be with him.” This law reflects the wonderful justice in the Mosaic Law. If a man sold himself to another man and the buyer knew that the one who sold himself was going to go free on the year of Jubilee, then the price the person sold himself for would depend on how long it would be until the Jubilee. So similarly, if the man is going to be bought back from the buyer, the price would depend on how long until the Jubilee. The man who is selling back the man who sold himself will have to hire a worker to replace him, so the cost of the worker from date of sale until the Jubilee would be the price the man (or a kinsman-redeemer) would have to pay to buy him back.
Note that the cost of buying the man back is not calculated based on how much the man originally sold himself for. People who are poor and desperate may agree to sell themselves for a lot less than they are worth just to have food and shelter. But if a man sold himself for less than he was worth, that does not change the fact that the one who bought him will now have to hire a man to replace him, so the cost of buying the man out of slavery may end up being more than the man originally sold himself for, but that is not the original buyer’s problem. The slave originally sold himself of his own freewill for an agreed-upon price, and now it will cost him the amount of hiring a man to replace him to buy him back.