Someone just asked this the other day, and it gets brought up in this sub pretty frequently.
It all depends on how you define "restaurant". If by "restaurant", you are simply asking about "eating outside the home", then such eateries have been around since ancient times. In the chapter "Baking and Cooking" by Nicolas Monteix in A Companion to Food in the Ancient World, the author describes the taberna of Ancient Rome from an anecdote written by Suetonius in the 120s A.D. The anecdote describes Claudius' love of meatballs purchased from these taberna, and Monteix writes:
"[These] "taverns" could offer a food service, and...this type of shop (here, the taberna in general) could draw a large clientele. It therefore seems legitimate to look at these establishments, which carried on a trade in prepared food, in order to understand everyday food practices."
In a chapter of that same book by Mark Robinson and Erica Rowan, the authors state that:
"There is a widely held belief that Romans who lived in apartments did not cook and instead purchased all their food from the numerous tabernae spread strategically throughout the town. The nearby town of Pompeii contains dozens of food tabernae and there is no evidence of upper‐floor kitchens."
In a chapter by Christophe Chandezon, the author notes:
"Consumers could...purchase pieces of cooked meat, possibly accompanied by a sauce meant to imitate those favored by upper class gourmets. This is what the popinae and tabernae of Roman cities sold."
Chandezon also notes that ancient Greek kapêloi served a similar function to Roman tabernae. Author Stephen Mitchell confirms this in yet another chapter of the same book, detailing evidence of "dining out" in the Greek cities of ancient Asia Minor, noting that inscriptions on a collection of epitaphs found in the city of Corycus describes the professions of many of the city's citizens in ancient times:
"Almost exactly 25% of the professions are connected to the production or selling of food, perfumes, and drugs. They include nine market gardeners (kepouroi), 16 wine merchants, and four sellers of olive oil. Some shopkeepers simply traded natural products, including a fruit seller, a vegetable seller, a pistachio nut seller, and four butchers. The numbers of traders in these categories is quite small, no doubt because many households grew their own garden produce. On the other hand, there were more shops for foods that needed specialist preparation, including 12 bakers, four makers of cakes and sweetmeats (patissiers), four confectioners, and two sausage sellers. Interestingly, although fishing is mentioned as a profession, no fishmongers appear in this list. In addition there were evidently numerous traders who sold food and drink in bars and other establishments, including 19 bar owners (kapeloi), one tavern owner (tabernarios), seven innkeepers (pandokoi), and two sellers of hot food and condiments (thermopoles, pantopoles). Seven persons ran perfume or drug stores."
(It should be noted that both the Latin taberna and the Greek kapêloi had a more general looser sense along the lines of a "shop" rather than specifically referring to eateries only, so they could sell other things aside from food, but prepared food was one of the main types of goods sold out of tabernae and kapêloi.)
Ardle MacMahon describes the Roman taberna in more detail in the chapter "The Taberna Counters of Pompeii and Herculaneum" of the book Roman Working Lives and Urban Living. In his doctoral thesis, The Taberna Structures of Roman Britain, MacMahon describes these same businesses in Britain. Specifically, he gives some details of the archaeological discovery of a probable snack-bar in the Roman town of Caerwent, in Wales, dating sometime between the 1st and 4th centuries A.D., as well as to the possibility of a cook-shop in a Roman excavation in London, probably dating to around the same period.
It is clear from these studies that "dining out" and consuming food prepared by others for a fee has been around since ancient times.
Skipping ahead, /u/rkiga has posted in this sub describing the dining-out experience in 13th Century China during the Song Dynasty. A briefer answer about dining in China during the Song Dynasty is in this sub's FAQ written by /u/EastHastings.
In the same thread as rkiga's post, I gave a run down of the dining out experience in England, of which there is evidence at least as far back as the 1100s in post-Roman Britain (in Norman Britain, in fact). These "eating houses" were more like today's British pubs or "fast food" style service you find in North America and elsewhere. This kind of dining-out experience has been found continuously in Great Britain ever since, and spread to British North America just about as soon as the colonies were founded.
The concept of full service "restaurants" with that name, which included a dedicated waiter, and the ability to order sides at-will with whatever main dish you wanted, rather than choosing from a smaller set of main courses with predetermined side dishes for each, and paying at the end of the meal instead of at the beginning, and tipping the wait staff for the service--that all dates to 18th Century France, and spread to Great Britain by the end of that century, and to North American in the early 19th Century. The history of that type of dining experience is included in this answer provided by /u/dhmontgomery.