A lockfile is a file that records the exact version of every dependency a project installed, so that builds can be repeated. Package managers create it automatically, and it usually also records where each package came from and a hash of its contents.

It matters because without it, an install can pick up newer versions of dependencies than the ones you tested. With a lockfile, every developer and build server gets the same versions, which makes results predictable and makes it harder for a malicious new release to slip in unnoticed.

A lockfile protects only the versions it lists. When it is updated, the new versions are accepted, so changes to it deserve review, and it does not make a bad version safe if that version was locked in. It must also be used correctly, since some commands update it silently and others install exactly what it states.

To benefit, commit it to version control, install from it in automated builds with the strict option your tool offers, review changes to it in code review and update dependencies deliberately.