The message service is used by the React app component to subscribe to new messages and push them into the messages array, which is shown in the render method as a list of alert divs. If an empty message is received, the messages array is cleaned, and the messages are automatically removed from the UI.