If multi-factor authentication (MFA) or 2-factor authentication (2FA) has been enabled on your Office 365 account, then for legacy services that do not support it, you will need to create something called an App Password.
To create an app password, go to https://portal.office.com and click on your profile image in the top right and then My account. Under Security & privacy click on Additional security verification. At the bottom of this page, you will see Create and manage app passwords. Click on Create and give it a name (for example, if this app password is for your iOS mail client, give it a name of “iOS mail client”). Put the password straight into the application, do not write it down. If for any reason you need the password again, re-create a new one.