Underrated? I think he lucked out in being allowed to play alongside Bayern's golden generation, getting to score tons of goals at the expense of his team's cohesion. I think quite clearly him (and Podolski) starting against Italy in 2012 cost Germany their chance at the Euros, a mistake that had to be rectified at half time. It's of course not all about him, but Bayern began their current period of utter dominance and won the CL final the moment he was dropped for Mandzukic (who wasn't even that highly rated at the time).
His CV after Bayern (Fiorentina, Besiktas, Wolfsburg, Stuttgart) also kind of speaks for itself.
1. It was not including him against Italy that cost Germany the semi-final, it was playing both Ozil and Kroos and shifting Ozil to a RW role which he was not familiar with at all having never played there for Germany or Madrid consistently. Ozil was playing well at AM throughout the tournament and moving him to an unfavoured position completely threw off Germany's tactics.
But yes, pin all the blame on Gomez and ignore his goals against Portugal and Holland in the group stages, which actually helped Germany go that far in the tournament.
2. Bayern reached the UCL final the previous season with Gomez playing as the main striker, a season where he scored 13 goals in 14 UCL matches (41 in 52 overall). That final should've been won by Robben, or had Bayern simply defended a set piece. Yes, I will concede that Mandzukic gave Bayern an extra dimension with his holdup play, but lets not forget that Bayern were already arguably the best team in Europe before he came. And Mandzukic was not the sole reason for Bayern winning, Martinez coming into midfield had a large impact as well.
3. His record after Bayern? He suffered two injuries at Fiorentina right after he signed having already had a long term injury at the start of 12/13 season with Bayern (the reason why Madzukic was given as starting role ahead of him that season). Even then, he scored enough goals at Besiktas (26 goals in 30 matches) and then at Stuttgart (8 in 16) to give him a place in both the Euro 16 and WC' 18 squads.
And why won't you consider his record before Bayern? You know, the reason why Bayern paid a record 35 ME to sign him in the first place? His record then was 79 goals in 106 matches in the 3 seasons prior to joining Bayern (including 11 in 14 European matches, incase you wanted the argument that the Bundesliga was poor then).
Overall, removing his time at Bayern, his record still 165 goals in 345 matches, which is very impressive considering this is including his latter years where he has aged and also injury ridden seasons. Overall, he is easily one of the best strikers of his era but sheer goals scored and is a victim of his generation in terms of the style of football preferred over what he played. But no one can doubt his goalscoring abilities.
EDIT: Btw Lewandowski's goals/min ratio for Bayern is 105 goals/min. Gomez is 99 goals/min and Gomez wasn't a favoured striker in two out of his four seasons. But yes, Lewandowski is/was the best striker in the world while Gomez is average