The Tanakh does not hold anyone to a perfect keeping of the law, but it does require repentance when sin is committed. Once the sin is understood, once the sin is understood, is punished.
Repentance, obedience, trusting in G-d are the key concepts.
We see this in David. As you know, he committed terrible sins, but once he was confronted by Nathan the prophet, he was forgiven because he repented at once, sincerely in his heart. This is what the Lord demands--true repentance (which means turning from the transgression).
And David said unto Nathan, I have sinned against the LORD. And Nathan said unto David, The LORD also hath put away thy sin; thou shalt not die. - 2 Samuel 12:13
One of the most beautiful and powerful of Psalms is 51, David's psalm of repentance. (You really should read the whole thing)
Psalm 51:1-3, 9, 11-12, 17 KJV
[To the chief Musician, A Psalm of David, when Nathan the prophet came unto him, after he had gone in to Bathsheba.] Have mercy upon me, O God, according to thy lovingkindness: according unto the multitude of thy tender mercies blot out my transgressions. Wash me throughly from mine iniquity, and cleanse me from my sin. For I acknowledge my transgressions: and my sin is ever before me. ... Hide thy face from my sins, and blot out all mine iniquities. ... Cast me not away from thy presence; and take not thy holy spirit from me. Restore unto me the joy of thy salvation; and uphold me with thy free spirit. ... The sacrifices of God are a broken spirit: a broken and a contrite heart, O God, thou wilt not despise.
In Nehemiah's confrontation with those who were working and trading on the Sabbath is a good example of working on the Sabbath:
In those days saw I in Judah [some] treading wine presses on the sabbath, and bringing in sheaves, and lading asses; as also wine, grapes, and figs, and all [manner of] burdens, which they brought into Jerusalem on the sabbath day: and I testified [against them] in the day wherein they sold victuals. There dwelt men of Tyre also therein, which brought fish, and all manner of ware, and sold on the sabbath unto the children of Judah, and in Jerusalem. Then I contended with the nobles of Judah, and said unto them, What evil thing [is] this that ye do, and profane the sabbath day? Did not your fathers thus, and did not our God bring all this evil upon us, and upon this city? yet ye bring more wrath upon Israel by profaning the sabbath. - Nehemiah 13:15-18 (see also Amos 8)
In Numbers:
30 But the soul that doeth presumptuously, whether he be born in the land, or a stranger, the same reproacheth the LORD; and that soul shall be cut off from among his people. Because he hath despised the word of the LORD, and hath broken his commandment, that soul shall utterly be cut off; his iniquity [shall be] upon him. And while the children of Israel were in the wilderness, they found a man that gathered sticks upon the sabbath day. - Numbers 15:30-32 (the punishment is not the same but the sin is just as serious)
The Lord demands trust (faith/belief in) from His people. The spies who refused to enter the Land, and the people who followed them, in fear and lack of trust in G-d, (because the did not trust that He would provide for and protect them when they entered the land), were never allowed to enter, they spent 40 years in the wilderness. Only Caleb and Joshua were allowed to live and enter the land after the 40 years.
Joshua and Caleb pleaded with the people to trust God and enter:
If the LORD delight in us, then he will bring us into this land, and give it us; a land which floweth with milk and honey. Only rebel not ye against the LORD, neither fear ye the people of the land; for they [are] bread for us: their defense is departed from them, and the LORD [is] with us: fear them not. ... 11 And the LORD said unto Moses, How long will this people provoke me? and how long will it be ere they believe me, for all the signs which I have shewed among them? - Numbers 14:8-9, 11
They refused to obey, so the Lord punished all the adult men.
For the LORD had said of them, They shall surely die in the wilderness. And there was not left a man of them, save Caleb the son of Jephunneh, and Joshua the son of Nun. - Numbers 26:65
Over and over, the Lord repeats Himself saying, He punished His children because they polluted His Sabbaths.
Because they despised my judgments, and walked not in my statutes, but polluted my sabbaths: for their heart went after their idols. - Ezekiel 20:16
Thou hast despised mine holy things, and hast profaned my sabbaths. - Ezekiel 22:8
Blessings to those who obey in faith:
The Lord foretold that the people would sin against Him. He promised blessings if they would obey and curses if they willfully disobeyed. As far as blessings are concerned, here are two very concrete examples of God's provision for those who keep the Sabbaths:
For instance, after the Exodus and before the giving of the 10 commandments, the Sabbath was given in the context of the giving of manna.
In Exodus 16,
the people were only instructed to gather what they needed, and no more, for any given day. Of course, some disobeyed and were chastised. The extra mana they gathered to save for the next day produced worms and stank. However, on the sixth day, they gathered twice as much and on the Sabbath, the food was still good to eat!
This was the Lord's gracious provision--the keeping of Sabbath will not harm your family-because the Lord provides.
Again, in the giving of the Sabbath year command, we see the same blessings promised. If obeyed, the people would reap three times as much from their harvest in the sixth year!
Leviticus 25:2-6
Speak unto the children of Israel, and say unto them, When ye come into the land which I give you, then shall the land keep a sabbath unto the LORD.
Six years thou shalt sow thy field, and six years thou shalt prune thy vineyard, and gather in the fruit thereof;
But in the seventh year shall be a sabbath of rest unto the land, a sabbath for the LORD: thou shalt neither sow thy field, nor prune thy vineyard.
That which groweth of its own accord of thy harvest thou shalt not reap, neither gather the grapes of thy vine undressed: [for] it is a year of rest unto the land.
And the sabbath of the land shall be meat for you; for thee, and for thy servant, and for thy maid, and for thy hired servant, and for thy stranger that sojourneth with thee,
Leviticus 25:22-26
And the land shall yield her fruit, and ye shall eat your fill, and dwell therein in safety.
And if ye shall say, What shall we eat the seventh year? behold, we shall not sow, nor gather in our increase:
Then I will command my blessing upon you in the sixth year, and it shall bring forth fruit for three years.
And ye shall sow the eighth year, and eat [yet] of old fruit until the ninth year; until her fruits come in ye shall eat [of] the old [store].
Once we see our sin clearly, God expects us to turn from it, in repentance. He promises to bless you when you do.
If my people, which are called by my name, shall humble themselves, and pray, and seek my face, and turn from their wicked ways; then will I hear from heaven, and will forgive their sin, and will heal their land. - 2 Chronicles 7:14
So, is it all or nothing? Yes. But it is not about perfection either.