"For the law was given by Moses, but grace and truth came by Jesus Christ."
John certainly does not mean that no grace or truth existed before Christ came, but that the "fullness" of grace was revealed in Christ. In contrast to the old covenant system reflecting in the law of Moses, the life and ministry of Christ completely overshadowed it. John uses superlative expressions like these to describe the coming of Jesus into the world: "glory," "full of grace and truth" (verse 14), "his fullness," "grace for grace" (verse 16). It was like twilight giving way to noonday brightness.
But take note that grace had been in the world from the beginning. Paul speaks of "grace, which was given us in Christ Jesus before the world began." 2 Timothy 1:9. Jeremiah spoke of "grace in the wilderness" (Jeremiah 31:2). Noah found grace in the eyes of the Lord (Genesis 6:8), and so did many other Old Testament characters. But the fullness of grace appeared in the person of Jesus. The law revealed the will of God, but grace gave the power to keep it. "Where sin abounded [through the law operating to expose it], grace did much more abound" Romans 5:20.