Google prefers that clients use OAuth2. If they don’t support it, as is currently the case with K9, it wants you to set up an app password and make some other settings changes. See:
https://forum.k9mail.app/t/solved-cannot-add-new-gmail-account-authenticationfailed/2190
for some information on this - or search for:
google app passwords
in this forum.