Maybe you are sleep texting? JK
Have you installed any new apps recently (the last day or two)? Also, was it just your husband that received this or did any of your other contacts receive strange messages from you?
You could try installing a malware / antivirus app and have it scan your phone. A virus is highly unlikely but you may have gotten malware from an app you installed.