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."