I remember reading that on 1800 orcso the most literate societies in the Atlantic World were New England in the US and Scotland. When did Scotland become so literate?
There are a couple of factors in play.
Scotland has a long tradition of university level education. Universities traditionally relied on papal bulls to establish their legitimacy and protect their autonomy from local civil interference. Compared to England, Spain, France, and Italy, Scotland was a relative latecomer to university level education, but where it distinguished itself was how quickly it opened more.
So, Bologna (11th century), Paris and Oxford (12th century) had been established for hundreds of years when Saint Andrews was officially established in 1413. However, where England got to two universities, Oxford and Cambridge, by the 13th century, it then didn't establish any new universities until the 19th century. By contrast, Scotland waited only 40 years to establish its second university, at Glasgow. By the end of the 15th century, they had another, at Aberdeen. So, Scotland began the century with no universities, and finished with three, one more than neighbouring England. Even more crucially, Scotland passed a law in 1496 that required the eldest sons of landowners to be schooled in Latin, law, and the liberal arts; this created a large, literatre, administrative class.
The other extremely important factor was the Reformation. Scotland was a relatively early adopter of the reformed tradition - presbyterianism is essentially a Scottish invention. One important concept in the reformed faiths is sola scriptura, the idea that religious authority rests in the Bible, and in the Bible alone. Obviously, for someone to derive their spiritual knowledge from the Bible, it was important that the Bible was presented to them in a language they could understand, rather than Latin. This is why the early reformers thought it was so important to produce vernacular translations. And of course, it would be even more effective if people could actually read and study their own Bibles. So, when the Reformation took hold in Scotland, and the existing Catholic schools were closed, the reformers established a national system, organised by presbytery. There was a degree of back-and-forth during the Restoration, but by 1696, Scotland had enacted a law providing schools in each presbytery, funded by local landowners. Such endeavours tend to be a virtuous circle, and successive generations were increasingly literate. In the next century, Scotland was a leading centre of the Enlightenment, particularly in Edinburgh.