Aliya Summary: The Torah prescribes the redemption process for a Jew sold into slavery to a non-Jewish master. The same formula described earlier (Fourth Aliya) is employed. Either the slave himself or one of his relatives refunds the master the amount of money that corresponds to the years remaining until the Jubilee — when the slave will go free even if he had not been “redeemed.” The Aliya concludes with a brief mention of the prohibition against idolatry, and the requirement that we observe the Shabbat and revere the Holy Sanctuary.
Rashi explains the insertion the prohibition against idolatry: When exposed to owners/people with different ideals, the slave might be temped to act like them, and if they don’t keep Shabbat, maybe he would follow. If they served idols, perhaps he would too. The placement is therefore a warning to be weary of our surroundings and negative influences, both blatant and subtle.