It first appeared in an article in the Melody Maker in the 1920s, but - as Emeritus suggests - the origin prior to that is unknown. Perhaps that was the origin!
Certainly, the word 'gig' meant fun/merriment as far back as the 1700s, so perhaps there was a suggestion of people playing just for the heck of it.