You need a backup with the iMessages on it for this to work. You have to restore from a backup that contains the deleted messages using either iTunes or restoring from an iCloud backup. To use the iCloud backup, you must first wipe the device and then restore using an iCloud backup.To restore from an iTunes backup, click on restore backup in iTunes and choose the backup that contains the iMessages. That's it.