taken to be a compound of gain- "in opposition to" (going back to Middle English yein-, gein-) + giving, gerund of give entry 1 — more at gainsay
Note: All usage of this word is based on a single instance in Shakespeareʼs Hamlet (V.ii.), though gain-giuing is only the reading of the First Folio (1623)—the second quarto of 1604, in which the passage first occurs, reads gamgiuing (game-giving in the quarto of 1611). The notion that the word means "misgiving" is completely conjectural, as gain- does not have the meaning "mis-."