The server obtains this value from the header section of the message. This is not Unique-ID value (Uid) assigned by the server to each message in the folder. For instance, if the message is moved between folders, its UID changes while Message-ID does not.
Usually, Message-ID is assigned to the message when it's composed. Thus, Message-ID identifies the message content. For instance, if the same message is placed into the IMAP4 folder twice, both copies will have the same Message-ID (while their Uid values will be different).