Why was the law given if it was impossible to keep?

The law was given to show mankind that they could not measure up to God's standard of holiness and righteousness, serving as a yoke that highlighted their sin.

Watch the Teaching: Why Christ Was Born Under the Law — Galatians Chapter 4