If you have set Mail up on Snow Leopard or earlier to access iCloud Mail, and if you have also enabled 2-step verification on your Apple ID, you will find your usual Apple ID password doesn't work. Apple are now requiring app-specific password for third-party applications to access iCloud if you have set up two-step verification (if you haven't set this up you won't be affected).�
Since Mail on Snow Leopard and earlier was not intended to access iCloud you will have to generate a password for it. Go to http://appleid.apple.com; click 'Manage your Apple ID' and sign in (you will be prompted for an access code sent to your trusted device).�
Select 'Password and Security'; click 'Generate an App-Specific Password' and follow the instructions. Once you have the password, copy it and paste it into the password field in the Account settings. You should also keep a note of it (though you can generate a new one if required).