Actually, Azhar's opening stats are massively inflated by the purple patch he had in 2016-17. You take out his 1 innings (302* against a poor West Indies bowling attack in Dubai) and his opening average becomes less than 40.
Babar averages in the mid-20s at #3. Also, it's important to realize that his natural position in Tests isn't really #3, nor does it suit the team combination. In case of an early wicket, he will be forced to come out immediately against the swinging ball. And we all know that he is a nervous starter in Tests and loves to drive the pacers early on. Babar coming out at Pakistan 1 down for 0 after 0.4 overs against any good bowling attack would not fare too well.