Well, of course, the Israelites were afraid. Look at what was happening: thunder, lightning, a thick cloud covers the mountain, and a very loud trumpet blast (Exodus 19:16); the mountain is covered in smoke like a kiln because the LORD had just descended upon it in fire, and the whole mountain shook (Exodus 19:18); the trumpet got louder and louder, and God spoke in thunder (Exodus 19:19); the people are repeatedly warned to be careful lest "the LORD break out against them" (Exodus 19:22, 24).
In this passage two separate Hebrew words are used for fear. The first time fear is used the word is yr, which means afraid, terrified. The second time fear is used the word is yirah which means fearful as in respect to a superior. Yirah is used almost exclusively in reference to God as in the fear of God, the fear of the LORD or a pronoun referencing God.
The Hebrew word for test means not only to test but to train, to become accustomed to.
The Hebrew word sin is from the root word translated to miss, as in an archer missing the target, not reaching the goal.
So Moses is telling the people do not be afraid, God has appeared in this way to train you to become accustomed to Him, so you may not miss the mark but reach the goal of obeying His instruction.
LORD God Almighty, thank You for clearly setting Your unchanging standards before me. In a world where the rules are always changing, thank You that Yours are unalterable. May I always be in awe of You, respecting You as the One True Superior. I desire to reach the goal for Your glory and my good.
The repentant criminal fascinates me. The basis of his rebuke is, "Do you not fear God". This is the same idea as the second use of fear in Exodus 20:20.
Notice the criminal's confession; he admits death is the deserved punishment for his action, then pleads for Jesus to remember him. When God remembered in the OT, it was an act of grace and mercy. The first use of the word is in Genesis 8:1 when God remembered Noah. The second use is in Genesis 9:15-16 where God says He will remember His everlasting covenant. So when the criminal asks Jesus to remember him, he as asking for Jesus' grace and mercy. He is acknowledging Him as capable of granting the request as King. Jesus' response is grace and mercy exhibited to a repentant sinner. We often hear of death bed confessions and professions of faith. God has graciously given us this example.
Every time I read God's response to Job, I am forced to confess my own foolishness by acting and thinking as if I know. In these questions, God knows the answer is "Not only do I not know; I do not even have a clue". Yet just like Job, I act as if I do.
Almighty God, Sovereign LORD forgive me for questioning You and for acting as if I am You. Please Holy Spirit quickly remind me of who God is and what He alone does.