We see from Yeshayahu that the ultimate redemption depends upon doing what is right and just and observing Shabbat, as it says:
Thus said the Lord: Observe what is right and do what is just; for soon My salvation shall come, and my deliverance shall be revealed.
Happy is the man who does this, the man who holds fast to it: who keeps from profaning Shabbat and stays his hand from doing any evil.
Let not the foreigner who has attached himself to the Lord say: “The Lord will separate me from His people [and I will not be privileged to experience all the good that is reserved for Israel at the time of their redemption]”;
And let not the eunuch say: “Yea, I am a withered tree [for I have no children and no future].”
For thus said the Lord: “As for the eunuchs who keep My Shabbatot, who have chosen what I desire and hold fast to My covenant: I will give them, in My house and within My walls, a monument and a memorial, better than sons or daughters. I will give them an everlasting name, which shall not perish.”
And to the foreigners who attach themselves to the Lord to serve Him, to love the name of the Lord, to be His servants – all who keep from profaning Shabbat and hold fast to My covenant: “I will bring them to My sacred mount and let them rejoice in My house of prayer. Their burnt offerings and sacrifices shall be welcome on My altar; for My house shall be called a house of prayer for all peoples.”
The word of the Lord God, Who gathers the dispersed of Israel: “I will gather still more to those already gathered.” (Yeshayahu 56:1-8)
The Sages comment on these verses: “If the Jewish people keep two Shabbatot properly, they will immediately be redeemed, as it says: ‘As for the eunuchs who keep My Shabbatot…I will bring them to My sacred mount’” (Shabbat 118b).
At first glance, this dictum raises a question: why do the Sages state that if the Jewish people observe two Shabbatot they will immediately be redeemed? Don’t these verses imply that the redemption is also dependent upon justice and righteousness? The answer seems to be that if the Jews keep two Shabbatot properly, they will also be just and righteous, because keeping Shabbat liberates one from his enslavement to money and wealth and refines his faith. This leads to the desire to pursue justice and righteousness throughout the week. This accords with another statement of the Sages: “The Jewish people will be redeemed only in the merit of Shabbat, as it is written: ‘You shall triumph by stillness (be-shuva) and quiet’ (Yeshayahu 30:15)” (Vayikra Rabba 3:1). In truth, we can achieve redemption by practicing justice and righteousness, because by doing so we are released from the bonds anchoring us to the material world and its impulses. Thus we perfect the six weekdays, allowing us to observe Shabbat properly and to increase our faith and closeness to God, through which we will merit redemption (See BB 10a and Devarim Rabba 5:7).
The Sages further state that by virtue of keeping Shabbat we merit living in Eretz Yisrael, as God said to Avraham: “If your children accept Shabbat, they will enter the land; if not, they will not enter” (Bereishit Rabba 46:9). And entering the land is the beginning of redemption.