Illicit means maybe against the law but definitely against the rules, for example an illicit affair. The word for against the law is illegal, from Latin, or unlawful, from Germanic. I guess the Germanic cousin of "illicit" would be "forbidden."

Extramarital affairs are against the law in many countries and 17 US states. “Illicit affair” is potentially a holdover from when it was illegal more places, not just a conflating of against the rules with illegality.

https://en.wikipedia.org/wiki/Adultery_laws