...
This phrase is believed to have its origins somewhere in the 12th century, as that’s when a scot was a tax a person would have to pay in England.
What’s a scot, you ask? Well, according to Robert Hendrickson’s The Facts On File Encyclopedia of Word and Phrase Origins, a scot “was a municipal tax in 12th-century England.” Hence, if someone were to avoid paying their taxes, they were getting away “scot-free.” Or in other words, they were getting away tax-free. Eventually, this phrase went on to describe, not just the avoidance of taxes, but people who avoided any sort of punishment or precarious situation, slipping away without harm.
https://knowyourphrase.com/scot-free