God proclaims his name to Moses as
Yahweh, Yahweh, the compassionate and gracious God, slow to anger, abounding in love and faithfulness, maintaining love to thousands, and forgiving wickedness, rebellion and sin. (Ex 34:6-7a, NIV)
A few verses beforehand we read
I will have mercy on whom I will have mercy, and I will have compassion on whom I will have compassion.
Both seem to point to divine election not related to man's works.
Then we have Moses' words in Deuteronomy:
Yahweh did not set His affection on you and choose you because you were more numerous than other peoples, for you were the fewest of all peoples. But it was because Yahweh loved you and kept the oath He swore to your forefathers that He brought you out with a mighty hand and redeemed you from the land of slavery, from the power of Pharoah king of Egypt. Know therefore that Yahweh your God is God; He is the faithful God, keeping His covenant of love to a thousand generations of those who love Him and obey His commands. (Deut 7:7-9, NIV)
It's safe to say at the very least that the Pentateuch teaches entry into covenant with God through His grace and at His initiative. Law-keeping is declared as a requirement to remain in the full blessings of the covenant, but the law and the sacrifices, through which law-breaking can be covered, are themselves an expression of God's grace - John 1:16-17 states this explicitly, but it also comes through strongly in Deut 4:8. It's possible to say quite a lot about the relationship between the law and grace, http://www.bible-researcher.com/grace.html has some good points in section 6.
But my favourite OT passage about grace isn't from the Pentateuch. When I read Is 19 I can't help thinking that it must have brought home the offence of grace to the original hearers, because it applies it to their historical enemy. Isaiah's prophecy about Egypt starts out with lots of disaster and destruction, and I can imagine them cheering, and then there's a sudden switch at v18:
In that day five cities in Egypt will speak the language of Canaan and swear allegiance to Yahweh Almighty. ...
In that day there will be an altar to Yahweh in the heart of Egypt, and a monument to Yahweh at its border. It will be a sign and witness to Yahweh Almighty in the land of Egypt.
Josh 4, anyone?
When they cry out to Yahweh because of their oppressors, He will send them a saviour and defender, and He will rescue them.
Etc. In summary: Yahweh will treat Egypt in the same way as He has treated Israel, with no need for a reason. I can't read that and not see grace oozing out of it.