I could have sworn that there was an old Monthly article that discussed precisely this question in some detail, but the closest that I could find in a few minutes on Mathscinet is the following article addressing the case $g(x) = 1/x$:
MR1641972MR1641972: Cheng et al, “When does $f^{-1} = 1/f$?”, Amer. Math. Monthly 105, number 8.