How does a wifi module work?
I’m assuming your question is about implementation, i.e., how would I use it? I can only speak to one specific WiFi System on a Chip (SoC) the ESP8266.
Out of the box, the chip responds to a set of “AT” commands, much like the old Hayes modem command set. These commands are issued and results received over UART. Using it in this fashion basically wastes the microcontroller on board, as you need another controller to issue commands and evaluate results.
Also freely available for this SoC is an environment called NodeMCU, that provides a high-level language and a file system, allowing you to write complex programs and store them for automatic execution when it boots.
Within this environment, you can monitor sensors and log data to an Internet server, even implement a mini web server. The language, called Lua, is object-oriented and event-driven; it’s fairly capable.