You usually can't get malware from opening a text. You'll most likely need to click on a malicious link or attachment first to get malware installed on your phone. While it's unlikely for your phone to download malware from opening a text, researchers have shown a phone can get hacked by receiving a message. Keeping your phone updated is the best way to have the latest security patches to prevent this from happening.