Reinstall mac os x 10.10 yosemite; never had mac os license assigned to my icloud account
It may be asking you for the iCloud account that was originally used on the machine.  Try to get the iCloud account/password that was originally used on the machine, if it was a company machine, and de-register it with that iCloud account so you can register it on yours.

There may be no need to buy a license.  If the current OS is Mavericks or higher, upgrading is free.  If it is older than you should buy a license.