The idea of encasing a filling with a flour crust apparently goes back thousands of years. Pie has been a part of culinary culture through the ages, from ancient Egypt, through Greek, Roman and medieval times to present day. Early pies were typically filled with meat, and the crust was not always intended to be eaten. A pie offers a means of storing and preserving its contents and can be eaten as a hardy meal at home or on the go.

I found this BBC article useful as it gives a decent high-level history:

https://www.bbc.co.uk/bitesize/articles/zmtn2sg

I was interested to know more about the earliest recipe from approximately 2000 BC. This is apparently from the oldest surviving clay tablet cookbook in exitance. I was able to find additional details and a translation for Mesopotamian Wildfowl Pie (aka chicken pie):

Mesopotamian Wildfowl Pie

Last, here’s a great video about 18th century pie making. As a bonus, the gentlemen wears 18th century period clothing and makes a gelatin gravy out of pigs feet: