As was stated in the answer to this post made by D M, one idea of capturing in this manner is to open up the g-file for white's rooks to attack black's king. In the game this proved to be a very potent idea, and in general it's a good idea to open up lines for one's rooks against the enemy king if one intends to attack it.
But there is another point to letting the e-pawn hang and that is to gain some tempi for the attack. When black's queen spends one tempo on capturing on e3 with check, white responds by playing Kh1 (a move that white wants to make in order to clear the g-file for the rooks), so while black used a tempo to make a move that does nothing to bolster their defenses, white made a move that is crucial for the coming attack (gaining 1 tempo, relatively speaking). Next white improves the position of the rook on c1 by going to e1. Once again, this is done with a gain of tempo, since black's queen is exposed on e3 and needs to spend one tempo moving away. This way white manages to get two "free" tempi to make his position more ready for going on the attack while black had to strut around with their queen, arguably doing nothing to bolster their defenses.
So the pawn sacrifice had a two-fold purpose here, I would say. First, by capturing with the g-pawn white opens up an important line of attack against black's king. Secondly, by investing the e-pawn white gains some free tempi to use in order to make their position more ready to go on the offensive against black's king.
In general, material count is only one of many factors in evaluating a position, and while it may be the most obvious it is not always the most important one. In this example, Carlsen judged that his superior piece coordination and black's kingside weaknesses were more important positional factors than the material count, and seeing how the game went it is difficult to argue that his judgement was off.