The Israeli Supreme Court has put an end to a decades-old system that granted ultra-Orthodox men exemptions from military service.