And actually, I'm not certain that your lawyers were correct in stating that the work was illegal. It's illegal to operate an online casino in the US. That's not the same as it being illegal to develop software that can be used by an online casino. If the casino in question was serving US customers, then you might be considered an accomplice in a crime. If they were only serving customers outside the US, I seriously doubt you'd be guilty of any crime.
I concur that it was probably a more complicated legal matter, but our counsel was pretty confident that this would have been problematic.
Were they allowing US customers to use their site? If so, you were might have been in a gray area. I agree with your legal dept that it could have been problematic either way. Not necessarily illegal, but not worth the hassle.
This occurs more frequently in cases of sex tourism (most particularly in countries like Thailand), and online gambling.
A few years ago at a previous employer, we had a client in Costa Rica who made online gambling applications who hired us to do an application assessment (preventing cheating and things like that); and it was only after we had started performing the assessment that I happened to inquire in a meeting with our legal department as to whether this was actually legal for us to do.
As a result of that meeting, we had to stop work on the assessment immediately, and not do any invoicing, as our lawyer thought that charging for that assessment would be a pretty clear violation of the law.