I just helped a coworker who was having trouble setting up her Yahoo! email account on her brand new iPhone 4S. I have a backup Yahoo account and many friends who use Yahoo! email on their iPhones and was surprised at how much trouble she was having trying to get it working with hers. I used my phone and Yahoo! account as a guinea pig. I deleted my login credentials on my phone to try to figure out what was going wrong and had the same problem getting logged in. It turns out that since Yahoo upgraded their mail system in the last year, you have to add your mobile number to your Yahoo! account to use their push email service on a mobile phone. You'll need to login to Yahoo on a desktop or laptop computer to add it.
Once you are logged in to your account on your computer, go to the part where it says "Hi_________" , with your name in the Blank area. Mouse over and then click on the Account info option. From there you will need to give your password. Once you do, it will take you to another screen where you can update your contact information.
Just add your mobile phone number and you should get a text from Yahoo! shortly with a confirmation code. You won't need the code to get logged in, but may want to save it for a future need. (Not sure what that might be)
That is it. Just go back to the settings area on your iPhone and login.
Hope this helps!