There is a sense of works that we are required to have done first in order to earn something as a wage that is different from the sense of works that are intrinsically required to have the experience of doing something. For example, there is a difference between work that someone is required to have done first to earn a wage to pay for the opportunity to experience driving a Ferrari for an hour and the work of driving it that is intrinsically required to have that experience. The opportunity to experience driving a Ferrari for an hour can also be given as a gift that requires someone to do the work to have that experience, but where that work contributes nothing towards earning the opportunity to have that experience as a wage.
While there are many verse like Romans 4:1-5 that speak against works being required to earn our justification/righteousness/salvation/eternal life as a wage in the first sense, there are many verses like Hebrews 5:9 support that they require us to be doers of works in the second sense. Our salvation is from sin (Matthew 1:21) and sin is the transgression of God's law (1 John 3:4), so while we are not required to have first obeyed it in order to earn our salvation as a wage, having the experience of living in obedience to it is intrinsically the content of the gift of Jesus saving us from having the experience of not living in obedience to it. In Titus 2:11-14, our salvation is described as being trained by grace to do what is godly, righteous, and good, and to renounce doing what is ungodly, so we are not required to have first done those works in order to earn our salvation as the result and we are not required to do those works as the result of having first been saved, but rather God graciously teaching us how to have the experience doing those works is intrinsically the content of His gift of saving us having the experience of not doing those works.
In other words, the content of God's gift of eternal life is the experience of knowing Him and Jesus (John 17:3) and the gift of His law is His instructions for how to have that experience (Exodus 33:13, Matthew 7:23), not for how to earn eternal life as a wage.