It's a feature. The new fanless design iMacs whereby the screen falls out to aid cooling during high CPU intensive activity.
The screens are stuck on and require heat to loosen off the bonding strips that hold the screen on. These are one-time use and are replaced should the system require dismantling.
Has it been dismantled or repaired in the past, by Apple or otherwise?
Can you feel the sticky bonding strip around the back of the screen or around the chassis itself? If it isn't sticky or not there, then that's the reason it fell out.
On the plus side, if you fancy a hard drive upgrade, now's your chance.