Yes, but that’s not the sole requirement. In addition to serving a legitimate government purpose, a government order must also avoid being arbitrary or capricious. Every order has to meet both requirements, and this one only meets one of them. From the ruling:
“This Court finds that based on the analysis above, the Commissioner’s Order of October 20, 2021, violated the Petitioners’ equal protection rights as the mandate is arbitrary and capricious. The City employees were treated entirely differently from private sector employees, and both City employees and private sector employees were treated entirely differently from athletes, artists, and performers. All unvaccinated people, living or working in the City of New York are similarly situated. Granting exemptions for certain classes and selectively lifting of vaccination orders, while maintaining others, is simply the definition of disparate treatment. Furthermore, selected enforcement of these orders is also disparate treatment.”