Where did the word "brat" in reference to a spoiled child originate?

Solution 1:

brat etymonline

c. 1500, "beggar's child" ("... wyle beggar with thy brattis ...)

and the derogative/contempt sense:

a. ‘A child, so called in contempt’ (Johnson). In 16th and 17th centuries sometimes used without contempt, though nearly always implying insignificance; the phrase beggar's brat has been common from the first.OED

From Partridge:

brat noun

a child, especially a troublesome junior; a baby UK, 1505

Dalzell, Tom. The New Partridge Dictionary of Slang and Unconventional English, 2nd Edition.

This latter suggests an early usage sense of contempt. From aprons, rags, beggars children, the derogative meaning appears to have come early.