In the later middle ages, there was a class of lawyers who earned their livings making a great deal of fuss over minor legal cases. About 1560 they came to be called pettifoggers. They often had limited concern for scruples or conscience and the term was deeply contemptuous.
Petty, then as now, meant something minor or trivial (from the French petit, small), so that part is obvious enough, but where does fogger come from?
Theories abound. One of the better known, and quoted as fact in a few dictionaries, is that it originated in a German family named Fugger, who were successful merchants and financiers of the fifteenth and sixteenth centuries, based in Augsburg. German, together with Dutch and other Germanic languages, also had variations on fugger as a word for people who were wealthy or grasping about money, or whose business methods were disreputable. Hence in English fogger, dating from the later sixteenth century but long obsolete, was a word for an underhand dealer. The German word might be the source.
Another form used at the time was pettifactor, which could have come from an old sense of factor for a person who acts as an agent, so somebody who looks after small matters for others. However, most experts think that pettifactor actually came along later as a corrupted form of pettifogger. People were trying to make sense of this odd word fogger that didn’t then exist in the language and converted it to one they knew.
The lawyers called pettifoggers spent their time arguing about matters of small importance. The term became popular, and spawned derivatives like pettifogging. These survived the original term, which is now considered archaic, but we retain in the latter word the idea of somebody who places too much emphasis on trifles or who quibbles about minor matters.