This error message is usually because you enabled the Two-factor authentication for Apple ID and the you turned it off and you have the old Apple ID type.
The message pops up to activate the passcode for the Apple ID Two-Factor authentication as it is needed.
Most probably you have switched back to the normal Apple ID and it cannot upload the passcode on iCloud.
It is like the iPhone does not recognise the old type of the Apple ID
To resolve this sign out of icloud from all of your devices.
Sign back in in one of them and enable the Two-Factor authentication again
(Settings-iCloud-Tap on your Apple ID-Paswword and security-Two-factor)
When you set it up go to the settings and press on the notification and change your passcode again (you the use the same one)
Then the setting notification will disappear.
Then you can go to id.apple.com, sign in to manage your Apple ID, edit the security for you Apple ID and turn off the two-factor authentication if you don't need it or want it
You can use the apple ID again to sign into iCloud in all of your devices.
If the Apple ID type is not refreshed in your device either restart your device or sign out of iCloud and sign back in.