Jeremiah delivered at least two sermons about the Sabbath to try to focus Judah’s attention back to God. Even though the words in this sermon focus on what the people were doing (working on the Sabbath), it was more about the why (keeping the day holy). After all the warnings against idolatry and other sins, keeping the Sabbath was still singled out for attention.
Working, specifically trading at the city gates, was one more way the people had found to turn their backs on their God:
Jeremiah 17:22-25 Do not do your work on the Sabbath, but make it a holy day. I gave this command to your ancestors, but they did not listen or obey. They stubbornly refused to pay attention or accept my discipline. But if you obey me, says the Lord, and do not carry on your trade at the gates or work on the Sabbath day, and if you keep it holy, then kings and their officials will go in and out of these gates forever. There will always be a descendant of David sitting on the throne here in Jerusalem.
By the time this sermon was given, it’s likely that God already knew what their answer would be, and so the other half of the promises of blessings and curses came:
Jeremiah 17:275But if you do not listen to me and refuse to keep the Sabbath holy, and if on the Sabbath day you bring loads of merchandise through the gates of Jerusalem just as on other days, then I will set fire to these gates. The fire will spread to the palaces, and no one will be able to put out the roaring flames.