You can remember the meaning of 非法 with this easy mnemonic:
Not (非) knowing the law (法) doesn't give you the right to do something illegal.
Using mnemonics to remember the meaning of Chinese characters like can have an enormous impact on how long to learn Mandarin it takes.