Here is the difficult part, though.
It is not always illegal, there are tons of exceptions, and there are shifting standards over time.
As one example, seeking asylum has HISTORICALLY not been deemed "illegal". We had people from the Soviet Union and Eastern Bloc countries applying for asylum...