Its to show respect to the other player regardless of whether you won or not.
Its basically saying "You're pretty good, hope I can play you again!" in a more subtle manner.
its just two letters, not too hard to type. And now that everyone is saying gg (which is a good thing) you may come off as rude if you don't say gg. You could be an amazing person, but that's just how the community is now.
Then again you could talk on the chat, but that takes too much effort, especially after every game, when a nice little gg will suffice.