Harems are not illegal, although polygamy might be considered illegal because women in harems are not wives but concubines, so no marriage is involved.