The word — very variably spelled — appeared first in the US. It was applied to undersized or ill-formed cattle, or to some disreputable person. After the Civil War, it became a term of abuse specifically aimed at those white Southerners who were prepared to accept the measures imposed during Reconstruction, often because they would profit from them. It shifted a little later to mean any politician who was corrupt or an intriguer. It has softened since, being a term these days of only mild reproach for a scamp, rascal or minor rogue, often combined with the gentle admiration that doting mothers dispose on an amusingly mischievous child.
Where it comes from is a matter of some dispute, though the Scots tongue seems to be an intermediary. Some authorities point to the Scots’ word scoloc, the name given to the first-born son of a tenant of a monastery who was given to the church to receive an ecclesiastical education. Later, the word could refer to any monastic tenant, and got turned into scallag for a farm servant or rustic person, also latterly a way of addressing a boy. And there’s also the word scurryvaig for a vagabond, lout or slattern, which might be an influence, if not the source. Either way, it looks as though Latin is involved, since scoloc is really the same word as scholar (from Latin schola) and scurryvaig may have originated in Latin scurra vagus, a wandering fool (scurra is also the source of our scurrilous).
Its abbreviation, scally, is widely known in the north-west of England, especially around Liverpool, for a roguish self-assured young person — typically male — who is boisterous, disruptive, or irresponsible.