Scholars believe Bach wrote this work sometime between 1703-1707 during his years at Arnstadt as a church organist there. Bach was eighteen and already had a reputation as an organist and authority on organs. The church had a new organ and asked Bach to examine it, and they gave him the job of organist. Bach eventually got into trouble for his overly creative extemporizing on the organ. Between the congregation and priests complaining about his playing, he finally got tired of it all and resigned. While at Arnstadt he also got into trouble for complaining about a bassoonist's playing and getting in a fight with him on the city street.
The Little G Minor Fugue is based on this subject:
The fugue is for 4 voices and the theme is first stated in the soprano, then the alto, tenor and bass. Bach puts the tune through his imaginative counterpoint and it comes out interlaced between other tunes and parts of tunes until it makes its way to the end.
A fugue is more than just a name for a musical piece. It is a way to compose a musical piece too. Bach is the supreme master of this compositional technique, so much so that even if the listener knows nothing about how a fugue 'works', a Bach fugue can still make musical sense. This fugue only takes a little over 4 minutes to play, and Bach fills those 4 minutes with a wealth of variety while still keeping the subject close at hand and discernible. The fugue has come across to some as being boring and academic, but in the hands of a master like Bach it can be interesting and enjoyable.