the Rambam in yesodei torah says that stars are creatures with intellect. how do we reconcile this with modern science which says that they are merely inanimate balls of hydrogen and helium gas.
The Rambam himself addresses your question. He writes the following in Moreh Nevuchim regarding the science in the Gemara:
Moreh Nevuchim (3:14):
אל תדרוש ממני להתאים את כל ענייני האסטרונומיה שהם ציינו אל המצב כפי שהוא, כי המתמטיקה היתה לקויה באותם זמנים. והם לא דנו בזאת מבחינת שהם מוסרים אמרות אלה מפי הנביאים, אלא מבחינת שהם היו חכמי אותן תקופות במקצועות אלה או שמעו אותן מפי חכמי אותן תקופות.
Do not ask me to reconcile all matters of astronomy that they (the sages) stated about astronomy with the actual reality, for the science of those days was deficient, and they did not speak out of traditions from the prophets regarding these matters. Rather because they were the wise of that period in these matters or because they heard them from the wise of that period.
As such, the Rambam would tell you not to try to reconcile his approaches with our conventional scientific understanding. Like the sages, he was basing his teachings on the knowledge of the philospophers and mathematicians of his own time.
When they landed a man on the moon, one great rabbi (R' Yaakov Kamenetsky, I think?) observed: "well Rambam was quoting Aristotelian philosophy and thought the moon had an intellect; Ramban was a kabbalist and said it's a ball of mineral. Looks like Kabbala just beat Aristotelian philosophy."
I think that both Aristotle and Maimonides relied on the science of their day which was wrong in many ways. Yet, the Rambam, unlike his predecessors, did not believe in the efficacy of astrology. In Yesodei Torah, I do not think the Rambam literally believe that beings exist in these inanimate balls of hydrogen and helium gas.
I recognize that he only knew the science of his time and some of his ideas which were based on that science are erroneous. An example is his view that upon death the person's knowledge (intellect) joins the sphere of intellect that circles the earth. Today we know this is the soul and not the flow of the active intellect. His and Aristotle's view of women was also erroneous and based on false science.
 By science, he said a woman had fewer teeth. But he was not a misogynist.