I'm talking about a place where you go and pay money so others cook your meal for you. Also, on a related topic, what about delivery food (my guess is that it's way more recent)
The idea of having a "restaurant" dates back to at least the first century A.D. In the excavations of Pompeii and Herculaneum, archaeologists have found multiple restaurants within the heart of the city.
Historian Wallace-Hadrill writes that there were multiple types of inns/restaurants/bars throughout Roman Italy. These establishments were designed for serving hot food to customers, often in establishments called 'popina' or 'thermopolium', though there is inadequate literary remains to be specific about their usage. There is a standing claim that there were 200 or so restaurants in Pompeii, but Wallace-Hadrill argues for a much smaller number, and further states that the counter style seen here was simply more common to other establishments.
Source: Wallace-Hadrill "Public Honour and Private Shame" in Urban Society in Roman Italy, edited by Lomas and Cornell.
Also see this thread from a similar question answered by u/koliano.
"Restaurants" as a concept have been around for nearly two millennia. However, the modern restaurant is essentially an 18th-century Parisian invention. I haven't gotten around to reading it, but I've heard wonderful things from multiple people in my field about Rebecca Spang's The Invention of the Restaurant: Paris and Modern Gastronomic Culture. If you're interested in the "modern" restaurant, I recommend starting there.