1. first of all, you need to test the internet connection. make sure that the internet is working fine. there is no network connectivity related error appearing on your device.
2. Now go to the account settings on your iPHone or computer, here you need to check the account settings. make sure that the user password is correct. in case, if you are typing the incorrect password. you need to reset it.
3. Let's go to the browser settings, you need to delete the cookies and cache files from your browser. also, you need to update the browser cache.
4. Sometimes, icloud account is not working because of the imap, pop3 or smtp server issues. so you need to fix them too.
Once you will make these changes into the icloud account. your device will start working fine.