The dish is believed to have originated in the late 18th or early 19th century in the UK, as a way to use up leftover roast meat. The first written recipe was found in a British cookbook from 1747, called "The Art of Cookery" by Hannah Glasse. Shepherd's Pie was initially called "Cottage Pie" and was made with beef, not lamb.
So, why is it called Shepherd's Pie if it's not made with lamb? Well, the name "Shepherd's Pie" was actually coined because shepherds were associated with sheep, and the dish was thought to be a hearty, rustic meal that a shepherd might enjoy. It wasn't until later that the dish became popular in Ireland, where it was often made with lamb or mutton.