Can you prevent iMessage texts from being deleted?

Solution 1:

No, there's no built-in way to archive iMessage history.

The only way to keep messages is to copy/paste them somewhere and then sync that to all your iCloud devices (or to back them up via your preferred archival method).

Solution 2:

I'm not sure if it’s what you're looking for, but there is a Message History setting that prevents messages from being auto-deleted after a certain amount of time.

You can find it in Settings -> Messages -> Keep Messages. Make sure it's set to Forever instead of 30 Days or 1 Year.