it is a joke to compare babar and virat.
babar gets to play either lower ranked sides or depleted 11 of top ranked sides, more often. That inflates his stats. He also seldom misses any matches which helps him not to lose any rating and maintain his ICC ranking.
here are some stats against some premier pacers
AVG vs starc, cummins, hazlewood:
in tests: babar - 36.4, virat - 41.6
in ODIs: babar - 39.5 (s/r 82), virat - 50.9 (s/r 90.4)
AVG vs boult, southee, henry:
in tests: babar - 83, virat - 53
in ODIs: babar - 24 (s/r 67), virat - 40 (s/r 100)
AVG vs rabada, nortje, ngidi:
in tests: babar - 28, virat - 40.5
in ODIs: babar - 50 (s/r 88), virat - 102 (s/r 78)
it is laughable how most critics and commentators just mention the rankings and average without checking the strength of the sides they are facing on a regular basis.