The law-gospel distinction is a vital principle in Reformed theology that separates the command to perfect obedience (which condemns the sinner) from the promise of free grace in Christ (which justifies the believer). Maintaining this distinction prevents us from turning the gospel back into a set of works, while allowing both to serve their proper roles in the life of the believer.
The contents of Scripture are primarily divided between the law and the gospel. The law serves to reveal our sin, restrain transgressors, and guide the believer in paths of righteousness. The gospel, however, is the joyful news that Christ has perfectly satisfied the demands of the law on our behalf, offering forgiveness and life as a free gift through faith alone.
As highlighted in the Formula of Concord: Solid Declaration — Article V §1, maintaining the distinction between law and gospel is a 'special brilliant light' necessary to rightly divide the Word of God. Without it, we risk robbing burdened consciences of the comfort found in Christ by blurring the line between God's command and His promise, effectively turning the gospel into a new law that burdens us instead of freeing us.
For the believer, the law and the gospel do not contradict one another but 'sweetly comply' through the work of the Holy Spirit. As noted in 1689 LBCF Ch.19 §7, the Spirit of Christ enables the regenerate person to love and keep the law not as a means of gaining acceptance, but as a fruit of being accepted in Christ. We obey because we are already loved, not to be loved.