Among other technologies, Selenium contains a WebDriver it uses to communicate with a browser. This WebDriver acts as a middle man between a programming language and the window. By entering commands in your chosen language, the WebDriver will interpret and enter them into the browser as if a user did it. Through the same mechanism the WebDriver can retrieve information from the browser window such as the data contained within elements.
The commands use the JSON Wire Protocol to serialize (convert from data in JSON format to an object) and deserialize (convert from object to data in JSON format) commands so they can be interpreted by HTTP servers. In order to let HTTP servers understand a request, it must be converted to a respective REST API command (e.g. GET, POST). This request is then sent to the HTTP server of the browser driver and also to the browser itself via HTTP. A response is then sent back via the same mechanisms.