Natural language output is created by the analysis and then the structured imitation of enormous amounts of text. In the case of ChatGPT, that source text was scraped from the internet and goes through 2021, according to reports.
When asked a question or presented with a statement, a chat AI finds information associated with the terms it's given and generates text about it, using algorithms that determine the next word based on its analysis of millions of existing, human-generated documents. The mechanism is analogous to the predictive text feature on a cell phone, though vastly more sophisticated. The result is usually clear, grammatically correct sentences. The output is also, however, generally bland, possibly repetitive, and sometimes inaccurate.
ChatGPT's output is not limited to ordinary prose. It can write code, plan a meal, create an outline, even craft a poem or song. It can be asked to write or rewrite in a particular style, or to revise and clean up written text.
Something to keep in mind is that text-generating AI, at this point in time, is a language tool, not a knowledge tool. If the AI does not have access to accurate information (as with ChatGPT's free option, which is not currently connected to any source of knowledge outside itself), it will still generate text —it just won't be accurate text. AI experts refer to this as "hallucination."
If you'd like to learn more about AI in and out of the classroom, here are some resources to check out. (Also look at the list of links on the "What Is an AI Chatbot?" page of this guide.)