If you go to Settings —> “Your Name” —> iCloud. Is Messages toggled on? If not, then toggle it on. Your messages will be uploaded to iCloud and you will be able to delete messages across all of your devices from any of your devices that are signed into iCloud. All of your attachments will also be stored on iCloud so you will save some space on your phone as well.
You will also need to turn on Two-Factor Authentication in order to turn on Messages in the Cloud. You should get prompted to do so when you toggle Messages on if you have not already set up Two-Factor Authentication previously.
If you have Messages set up on your Mac, you will need to open Messages, go to Preferences, click on iMessage, and check the “Enable Messages in iCloud” box.