A web server is just an application (i.e. software)* that you can install on your machine. Fundamentally, it's no different than, say, the game Minesweeper on your computer. It receives input and generates output, like a mathematical function f(x).**
When you play Minesweeper, you click the mouse and the action of clicking the mouse button ultimately gets handled by a device driver (also a piece of software) which ultimately registers that click event with the Minesweeper game that is running.*** The Minesweeper game handles the logic of updating the game. During that, Minesweeper will talk to another device driver that changes the pixels on your screen to reflect the current state of the game.
Similarly, a web server responds to external actions that come through a network cable, instead of a mouse cable, and the external action will be something like "Give me forum/post.php?board=1&reply=8052851"**** instead of "I just clicked your mouse." The application decides what to do with the input "forum/post.php?board=1&reply=8052851". In the process it will likely need to talk to another application***** called a database to retrieve some text which it then stitches together into a block of text in a format called HTML******. It then talks to another device driver that knows how to push that block of text out through the network cable, hopefully ending up at the machine that requested it.*******
In ASP.NET, for example, the web server is an application called IIS (Internet Information Services) and the device driver that gives IIS an HTTP request to process is called HTTP.sys.
* Sometimes the machine on which a web server runs is will be colloquially referred to as "the server" because the machine's entire purpose is to run the web server.
** It's not really a mathematical function because a function by definition has the same output for the same input. e.g. f(x) = x^2 will always have f(2) = 4 because it's a pre-defined mapping. A buzzword that's making its way throughout the programming world nowadays is "pure functions" which is the idea of reducing the number of functions whose output is always the same for a given input.
*** I say "ultimately" because there are a lot of other things that happen during the process. Your operating system sits between the device driver and the hardware.
**** The actual sequence of characters in the request might look like
GET forum/post.php?board=1&reply=8052851 HTTP/1.1
Connection: Keep-Alive
Accept: image/gif, image/jpeg, */*
Accept-Language: us-en, fr, cn
***** My answer to almost everything is "It's just an application."
****** Technically it can send anything back. Doesn't have to be HTML.
******* It doesn't send it out all at one. It starts by sending out a little bit, then a little more than before, etc. That is how machines communicate over the network.