I got a login loop in Ubuntu 18.04.5 LTS, startx works,
installed ubuntu-desktop and made it the default and the login loop persisted, reinstalled lightdm stayed the same,
after booting with startx, .xsession-errors.old shows the following at the end which I think might be the cause of the loop
systemctl: unrecognized option '--value' systemctl: unrecognized
option '--value' systemctl: unrecognized option '--value' systemctl:
unrecognized option '--value' systemctl: unrecognized option '--value'
systemctl: unrecognized option '--value' systemctl: unrecognized
option '--value' systemctl: unrecognized option '--value' systemctl:
unrecognized option '--value' systemctl: unrecognized option '--value'
systemctl: unrecognized option '--value' systemctl: unrecognized
option '--value' systemctl: unrecognized option '--value' systemctl:
unrecognized option '--value' systemctl: unrecognized option '--value'
systemctl: unrecognized option '--value' systemctl: unrecognized
option '--value' systemctl: unrecognized option '--value' systemctl:
unrecognized option '--value' systemctl: unrecognized option '--value'
systemctl: unrecognized option '--wait'
But I don't have any script in .profile, and have no idea where systemctl is being used with --value parameter at startup.