1560s, from petty; the second element possibly from obsolete Dutch focker, from Flemish focken "to cheat," or from cognate Middle English fugger, from Fugger the renowned family of merchants and financiers of 15c.-16c. Augsburg. In German, Flemish and Dutch, the name became a word for "monopolist, rich man, usurer."
A 'petty Fugger' would mean one who on a small scale practices the dishonourable devices for gain popularly attributed to great financiers; it seems possible that the phrase 'petty fogger of the law,' applied in this sense to some notorious person, may have caught the popular fancy. [OED first edition, in a rare burst of pure speculation]
However, OED also calls attention to pettifactor "legal agent who undertakes small cases" (1580s), which, though attested slightly later, might be the source of this. Related: Pettifoggery.