If you have recently completed a backup using iCloud, you can recover deleted messages on your iPhone by restoring the old backup.
Unfortunately you will need to reset your phone to factory settings before you can restore the backup. This means that anything added to your iPhone after the backup was taken will be deleted.
Also, something important to keep in mind is that you cannot check what was saved during the backup without resetting the phone and restoring the backup. The main indicator of whether it will recover your messages is the date (and whether they were still saved on your phone at the time the backup was taken).
1 – Open Settings, select the Apple ID at the top.
Then select iCloud, Manage Storage, Backups.
Here you will see a list of backups previously taken. Select the one for your iPhone to see the date it was taken.
2 – Now reset your iPhone to factory settings
3 – After it restarts and you enter the setup process, choose to restore iPhone from an iCloud backup. Then you can select the backup you want.