Right before this passage, the author of Hebrews writes, “For the law never made anything perfect. But now we have confidence in a better hope, through which we draw near to God” (Heb. 7:19). We see the goal: to “Draw near to God”. The means is not the law. The only effective means is Christ.
The law’s role here is to point out the deficiency of everything else to this most ultimate purpose. It points to the means that works - it points in its insufficiency (to that point, it was the best means we had) to Jesus’ sufficiency.