If we understand the correct outlook on the subject of greatness, we can see where the pagans are mistaken. The pagans believed that a man who had supreme intellectual powers and the divine presence resting on him was automatically a great man. They believed that the way to greatness was in amassing knowledge and wisdom. This is not so. Knowledge in itself does not have the power to change the inborn nature of a person.
Man is born with a yetzer hara, an evil inclination.
Only at the age of Bar or Bat Mitzvah is the yetzer hatov added. A person must work on themselves relentlessly to conquer and uproot the yetzer hara, and only then can he reach perfection. Throughout the generations, Hashem rested his divine presence only on those who ceaselessly labored to overcome their yetzer hara. Thus, to the pagans, whose innate nature was corrupt, prophecy and wisdom would have no lasting effect. This is what Hashem was showing them by giving them a prophet such as Bilam.