I do not understand why it took Apple so long to do basic management of text message (SMS) spam. I don't understand why the solution appeared over two releases. I don't get why the implementation is so obscure. And I don't get why I had to write this; even knowing the two necessary settings I can't find a good article on it. Apple's own documentation doesn't mention disabling notifications.
Anyway, as of iOS 15 you can finally turn off notifications for SMS sent from an unrecognized number. This is in addition to iOS 14 enabling sorting of unrecognized number SMS into a separate tab. (I think iOS 13 you could only filter iMessages, which is basically useless.)
First enable "Filter Unknown Senders". Unrecognized SMS messages go into a separate tab.