I believe the cryptographic property that this function is trying to verify is integrity:
Enveloped Public Key Encryption (EPKE) is the method of applying public key cryptography and ensuring that an electronic communication is transmitted confidentially, has the contents of the communication protected against being modified (communication integrity)
Looking at the function in isolation (without any business process context) makes it hard to be certain of what this check function is hoping to achieve, how it is called etc. but my best guess it to prevent a malicious actor from being able to subvert the check by impersonating another account
ecrecover will return the public key, paired with the private key, of the account used to sign this message - the problem with calling this function naively is a sort of "replay attack".
As a malicious actor, let's say that there is a benefit to me being able to impersonation public key P.
Let's also say that there's communication protocol where we give clients a message and ask them to sign it in order to verify their identity to authenticate them.
Let's also say that your system just naively took the contents of a message returned by the client and didn't check the hash of it matches up with the original message.
As a malicious actor, I would be able to impersonation P by looking at the blockchain for the messages that M has returned to you and inject one of those in my response. Ecrecover would return public key P and the check function would be subverted.