If you're talking about the United States, this question has been settled at the federal level by the Supreme Court for over a century. At the state level, the first vaccine mandate was in 1809. Most states have vaccine mandates for children, many of them with only medical exemptions. It's legal. It's not some great infringement on your rights.