He didn't deserve it (speaking from a 21st century perspective), but it was bad science. He said he could prove it and couldn't. He taught as fact that which was not provable as fact. He ticked off everyone he came into contact with, churchmen to professors to scientists, which is never a good course of action. He was right (partially--the Sun is the center of our solar system, not the Universe) but tried to make his case in the worst way possible.
Faith can never conflict with reason. The Pope's statement on Galileo and science/scripture conflicts. Excerpts:
The problem posed by theologians of that age [the time of the Galileo controversy] was, therefore, that of the compatibility between heliocentrism and Scripture.The Pope's 1996 statement on evolution. Physical evolution is not in conflict with Christianity. Excerpts:Thus the new science, with its methods and the freedom of research which they implied, obliged theologians to examine their own criteria of scriptural interpretation. Most of them did not know how to do so.
Paradoxically, Galileo, a sincere believer, showed himself to be more perceptive in this regard than the theologians who opposed him. "If Scripture cannot err", he wrote to Benedetto Castelli, "certain of its interpreters and commentators can and do so in many ways".(2) We also know of his letter to Christine de Lorraine (1615) which is like a short treatise on biblical hermeneutics.(3)
[snip]
In fact, the Bible does not concern itself with the details of the physical world, the understanding of which is the competence of human experience and reasoning. There exist two realms of knowledge, one which has its source in Revelation and one which reason can discover by its own power. To the latter belong especially the experimental sciences and philosophy. The distinction between the two realms of knowledge ought not to be understood as opposition.
It is necessary to determine the proper sense of Scripture, while avoiding any unwarranted interpretations that make it say what it does not intend to say. In order to delineate the field of their own study, the exegete and the theologian must keep informed about the results achieved by the natural sciences.Pope Pius XII's 1950 Encyclical, Humani Generis. Referred to in the 1996 statement. Excerpt:Today, almost half a century after the publication of the Encyclical [see link & excerpt below], fresh knowledge has led to the recognition that evolution is more than a hypothesis. It is indeed remarkable that this theory has been progressively accepted by researchers, following a series of discoveries in various fields of knowledge. The convergence, neither sought nor fabricated, of the results of work that was conducted independently is in itself a significant argument in favour of this theory.
... the Teaching Authority of the Church does not forbid that, in conformity with the present state of human sciences and sacred theology, research and discussions, on the part of men experienced in both fields, take place with regard to the doctrine of evolution, in as far as it inquires into the origin of the human body as coming from pre-existent and living matter - for the Catholic faith obliges us to hold that souls are immediately created by God.