Why do we use present perfect in this sentence: "Do you know how many people have walked on the moon?"
Does the present perfect show that the action might happen again, although it is not an ordinary thing?
In a sentence like "Portugal was/has been the most powerful country in the world", which one is correct? Because Portugal once was it, and it could be it again, but that is almost impossible to predict.
In your first sentence, the speaker is asking about the number of moonwalks from the time of the first to the present moment. There is no particular suggestion that there may be more moonwalks.
As there has been no moonwalk for over forty years, the speaker could have used the past simple, thinking of the years 1969 to 1972 when the moonwalks took place.
Portugal was the most powerful country in the world. - At some time in the past.
Portugal has been the the most powerful country in the world. - At some time between the establishment of Portugal and the present time.
As Portugal's days of international power are quite a long time ago, the past simple is far more likely than the present perfect.