Schools will mandate health as a required class, or more specifically sex ed as I assume you are referring to, sometimes for students who can't learn any other way, because their parents or guardians never taught them and they can't/won't ask anyone else. Also to try to persuade kids not to have sex in high school/middle school. And, for the kids who will anyway, the health class educates on how to protect yourself against STIs and pregnancy.
Even if you find some parts of health class gross, it really teaches you some important things to make sure that you stay healthy in your life. That's sort of why it's called "health" class. Besides, if you didn't learn this stuff now, you might go and try to get the information from less reliable sources later, and end up sadly misinformed on a lot of things about your health.