If you have 2factor authentication on on your account, you cannot log in on a Mac running OS X 10.10 Yosemite with your Apple ID and password. This is because logging in with 2 factor authentication is supported from Sierra onwards.
you can login tho, but you will need to use a different method. You will need to use a verification code instead of your Apple ID password. As your Mac is too old to generate verification codes itself, you will need to generate a verification code on a different apple device
See this instructions on how to do that
From your iPhone, iPad, or iPod touch
If your device is online:
- Go to Settings > [your name].
- Tap Password & Security > Get Verification Code.
From your Mac
- Go to Apple menu > System Preferences, then click Apple ID.
- Click Password & Security > Get Verification Code.