I don't understand -- Why is it illegal for a religion not to be taught in a public school?
Yes there actually is. And school accepting federal funds, and those not are rare as hen's teeth, must seperate religious classes from standard academics. All religions.There is nothing in the constitution that says a school can not teach religion, but the first amendment has been interpreted to mean government can not treat one religion differently then another. So if it teaches Islam for example it must also teach all other religions equally.
That is also where government runs into trouble putting up religious symbolism on public property. They are fine as long as all religions are treated the same on that property.