Before trying to restore data from an iCloud backup, ensure your device has the latest version of iOS. To do so, go to Settings, then to General, and then tap Software Update. If there is a newer version, follow the instructions to update the iOS.
Ensure you have a backup from which you can restore data. To check the latest backup you have on your iOS 7 device, go to Settings, tap iCloud, go to Storage & Backup, and then tap Manage Store. Under Backups, tap your device to see the date and size of the latest backup on it. The procedure to check this on an iOS 8 device isn't very different; go to Settings, tap iCloud, tap Storage, and then select Manage Store. Just as with an iOS 7 device, go to Backups, and then tap on your device to see the date and size of the latest backup on that device.
As you need to erase the content on your device before restoring the backup, go to Settings, then to General, tap Reset, and then tap Erase all content and settings. Next, in the Setup Assistant, tap Set up your device, and then go to Restore from a Backup. Sign in to iCloud, tap Choose Backup, and then select the backup to restore.