It comes from the 15th century word 'gig' which meant something that spins, i.e. whirigig.
Later usage adapted the word to mean other things, including at one time, a joke, and nearer to the mark - a dance.
Since every musician's dream job was playing dances and parties - which meant regular employment - the word became synonymous with a paying engagement.
I was given to understand the present definition was more modern and that it was a contraction of the word 'engagement', as indeed used by musicians referring to their work.
There is another (slightly dated) usage by musicans referring to a position in a band or orchestra etc. as a gig. (as in "I auditioned on Tuesday and I was obviously the best, so I got the gig") as well as the meaning of a live concert.
Bands in America don't use the word 'gig', they use 'show' instead. I have adopted this practice, because I think 'show' is a better word psychologically and 'gig' is one of the ugliest words in English.