There are two ways for you to save text messages on your iPhone.
Method 1: Backup iPhone Messages with iTunes
As we known, Apple provides the offical way for you to backup iPhone Messages is iTunes. When you make the backup in iTunes, all of the messages data will be included as well. So you could use iTunes to backup iPhone messages.
Step 1. Connect your iPhone with computer and launch iTunes. Click the device button
Step 2. Under Summary, click on Back Up Now in the Backup section. iTunes will start backing up your iPhone data as well as text messages.
Method 2: Backup iPhone Messages with iCloud
Another way that Apple provides you to backup data in iCloud. Just like iTunes, iCloud backup also will contain iPhone Messages. You can make the iCloud on your iPhone directly.
Step 1. Connect your iPhone with Wi-Fi.
Step 2. Go to Settings> iCloud> Backup to turn on iCloud Backup.
Step 3. Tap on Back Up Now to start the backup.
Kindly Reminder: iTunes and iCloud backup will not allow you preview the backup data. There data stored in iTunes are in SQLite database form. You can not open up that file except with a SQLite editor or a special third-party tool.