And well ye knew those amongst you who transgressed in the matter of the Sabbath: We said to them: “Be ye apes, despised and rejected.”
Regarding the Sabbath, Yahiya Emerick writes:
“The practice of doing no work on Saturday, known as the Day of the Sabbath, is so important to Jewish tradition that flouting its rules is punishable by death. (See Exodus 31:12-17.) Although many people assume that the Sabbath is meant to commemorate the day that God ‘rested’ after the labor of creating the universe, in fact, the Sabbath was instituted only after Moses and the Jews escaped from Egyptian slavery as a way to commemorate God’s favor. (See Dueteronomy 5:15.) For the Sabbath regulations see Deuteronomy 5:12-14.”
as well on the statmenet “Be ye apes” he comments:
The mention of the term apes is in recognition that primates often imitate whatever they see. Therefore, God, in equating the Sabbath-breakers with apes, is pointing out that they hopelessly copy whatever ignorant ways the cultures and nations around them practice. They will prefer to copy unbelievers and wrongdoers, which is, in fact, what repeatedly happened, if the records in the Bible are to be believed. The same story is mentioned in 7:163-166 where the people are further identified as fishermen who lived in a village by the sea. Some commentators have held that the wrongdoers were actually physically turned into apes, (and there is evidence that the Jews of Medina had a legend about it,) though it must be remembered that the Qur’an occasionally uses metaphorical, figurative or allegorical language. Ibn ‘Abbas (d. 687) was of the opinion that they were transformed thusly, but that it lasted for only three days. The Jewish Old Testament orders that Sabbath-breakers are to be put to death and that this rule is to be binding upon all Jews for all time (see Exodus 31:14-16, also Deuteronomy 5:12-14). Interestingly enough, there is a tradition from the Prophet, recorded in the Bukhari collection, that describes future followers of his who will make lawful things like adultery and liquor and who will be stingy. The Prophet concluded by saying that God will turn them into monkeys and pigs and that they’ll remain like that until Judgment Day. The commentators, both ancient and modern, understand that report figuratively and not literally, so this principle can legitimately be applied to interpreting this verse, as well.
Emerick, Yahiya. The Meaning of the Holy Qur’an in Today’s English (p. 829). Unknown. Kindle Edition.