Hello and welcome.
This can happen if:
-The App Store is offline
-You are having Internet connectivity issues
-If the Apple ID is new and was never associated with the Yosemite installer in the App Store
-Some Macs do not support Internet Recovery of the newer versions of OS X
Do you still have the gray OS X install discs that came with your iMac? If so, you could install it, run all software updates, then download/install Yosemite. You will need to remember the Apple ID login information that you used previously to "purchase" Yosemite, as it is no longer available to download otherwise. It will show up in the Purchased section when logged in with your previous Apple ID.
You could also visit an Apple Store, and they may be able to install Yosemite for you.
C