Two Factor Authentication on 10.10.5 Yosemite
You need to be running El Capitan or later.

See Apple KB - Availability of two-factor authentication for Apple ID

If your Mac can run Yosemite, it can run El Capitan.