After years of adding and removing users, the account files collect odd leftovers. pwck checks /etc/passwd and /etc/shadow for them, and -r keeps it from fixing anything on its own.
I’d run it read-only first:
sudo pwck -r
echo $?
sudo grpck -r
It reports lines with the wrong number of fields, duplicate user names, users whose primary group does not exist, home folders that are missing and users that appear in one file but not the other. grpck does the same for /etc/group and /etc/gshadow.
On a stock Ubuntu install you will already see a few warnings, such as system users like lp or news whose home folder does not exist. That is normal. What to look for is an account that only exists in /etc/shadow, or a duplicate name, because both point to hand editing or something worse.
The exit code helps in scripts. 0 means all is fine, and other values mean problems were found or a file could not be read; the manual lists each one.
Be careful without -r. In normal mode pwck asks whether it should delete bad entries, and answering yes too quickly can remove an account you still need. Take a copy of the four files before you let it change anything.
Further reading: pwck(8) manual page