I was lucky enough to get an early glimpse recently of what promises to be a deeply affecting exhibition charting Scotland's changing relationship with food over the last 400 years.

What struck me immediately upon viewing part of the National Library of Scotland's collection of the earliest hand-written and printed recipe books, some dating from 1683, was how sustaining Scotland's natural larder was, how central food was to daily life, and how it was second nature to source locally, seasonally and well. Home-grown vegetables, oatmeal and broth played a large part in the national diet across all social strata.

More than that, it's as clear as a well-made consommé that it was women - ordinary housewives, domestic servants and professional chefs - who were at the epicentre of almost every culinary endeavour, from brewing beer to taking deer off the hill, from baking bread to foraging and fishing, from growing kale and potatoes to running the kitchen account books. Receipts for sheep's heid, mutton, herring, chicken and eggs are carefully logged in one.

It shows how canny and inventive these women were in sourcing and cooking good food, often in the face of adversity; scarcity of supply was common (supermarket delivery lorries weren't yet even a twinkle in the industrial revolution's eye). There's even evidence - whisper it - that Glasgow was an early pioneer of street food, and a recipe for Glasgow Salad really means greens, not chips, were involved.

John Reid's The Scots Gard'ner (Fruits of the Garden and What To Do With Them), published in 1683 by David Lindsay in Glasgow, is the first gardening book, and probably the first published recipe book, to focus on the Scottish climate. Artichokes, asparagus, beans, peas, lettuce, apricots, peaches, raspberries, gooseberries, plums and potatoes, which he said when cooking "should be treated the same way as parsnips, but substitute sweet butter for milk and cinnamon".

It was not written just for the well-to-do; ordinary people would have been growing potatoes and other vegetables too. He also wrote a "Kalendar" for each month of the year, with tips on what one should be doing. On this copy there is handwritten notes by a previous owner, all to do with beekeeping.

A 1683 recipe for orange marmalade from the Countess of Sutherland at Dunrobin Castle, Golspie, is the earliest marmalade recipe held by the NLS (it was made as a paste and cut and eaten with a knife as forks only became available in the early 18th century). But there's also one for a "marmalade of cherries without much sugar", demonstrating that sugar was only affordable by the wealthy until around the mid-19th century when it became more plentiful. Making preserves was originally a hobby of landed womenfolk, as only they could afford the price of sugar. "To preserve quinces in Jily" is a recipe either the Countess knew herself or was given by a family member: most recipes were written for family reference, and passed down from one woman to another. There's another unattributed recipe, "To make Gellie of Rasps" contained in a leather-bound book complete with decorative clasp.

From the Burnfoot House of Langholm family recipe book are Stephana Malcolm's 1791 curry recipes, with that for Currie Powder (a mix of onions, cloves, garlic, cardamom, cumin seed, coriander, turmeric, whole ginger, cloves, mace, cinnamon) is the earliest recipe for curry in the NLS. Add cream and you have a Malaysian curry. Malcolm's brothers were in India at the time and she and her sister copied their instructions on how to make "mulgatawy" soup and Indian pickle and other curry recipes.

There's an exquisite book in which Catherine Jane Ellis of Glenquoich, Inverness-shire, has handwritten a recipe, dated 1856, for a leg of pork "a la Lady Elizabeth Villiers", complete with an ink drawing of the leg on a spit in the kitchen fire, being tended by a well-wrapped-up woman (the fattened pig, still in its byre, is also captured in ink in a drawing above the recipe). In another example, a charming ink drawing of a girl kneading dough in a downstairs kitchen, and another of a well-to-do group drinking afternoon tea, accompany a recipe for "excellent white bread without yeast" (as it was difficult to get yeast in the Highlands in those days, so soda and tartaric acid was used).

And in a travel journal from Ipswich to Edinburgh, dated 1862, there are lovely drawings of fishwives in Fisherrow, Musselburgh, carrying baskets of fish on their heads. Lots of big houses had French cooks but the food at the inns, notes the female diarist, was "terrible".

Long before restaurants burst onto the culinary scene, the traditional Scottish diet across appears to have been excellent, if simple and sometimes frugal. It makes you wonder at what point, and why, the Scots diet went so badly off course to create the modern obesity crisis, our destructive relationship with sugar and fat, poverty-related malnutrition, and a reputation for being the sick man of Europe.

The people writing these books would, of course, have been quite high up the social order, as crofters wouldn't have had the writing materials or would have been illiterate. Even so, they shine a light on how we lived then. I understand the plan is to transcribe and digitise the recipe collection so that members of the public can try their hand at making their own dishes at home. Thus Scotland's rich culinary past will be captured for the future.

Lifting the Lid: 400 Years of Food and Drink in Scotland runs from June 12, 2015, to November 1, 2015, at the National Library of Scotland, George IV Bridge, Edinburgh EH1 1EW. Entry is free.