I assume you are talking about this case: FORIS GFS AUSTRALIA PTY LTD vs THEVAMANOGARI MANIVEL.
For that amount, most people would be willing to break the law to keep
it, and good advice what to do would be “ask a lawyer”.
Needs citation. I certainly wouldn't: a) I think taking money that I know doesn't belong to me is wrong, b) even if I didn't believe that, the amount is so large the bank will certainly eventually come after it. The amount is so large I won't credibly be able to claim an innocent mistake. Simply hiding the money won't work, since the bank will be able to demonstrate that the money was deposited in my account, and I did withdraw it. I would be required to make restitution. This is exactly what happened to the defendant in the above case: they split up the money among friends and bought a house. The house is now being sold by the court, with the proceeds used to reimburse the plaintiffs.
Would a lawyer be allowed to give me legal advice to help me keeping
this money, for example by giving 500,000 each to twenty reliable
friends, moving to Panama, or whatever would allow me to keep and
spend the money? (Not asking whether two strategies that I came up
with in ten seconds would actually work).
Especially if it is advice if the form “X is illegal, but you can get
away with it”.
No. For example, the American Bar Association Model Rules of Professional Conduct, Rule 1.2 Scope of Representation & Allocation of Authority Between Client & Lawyer states:
(d) A lawyer shall not counsel a client to engage, or assist a client,
in conduct that the lawyer knows is criminal or fraudulent, but a
lawyer may discuss the legal consequences of any proposed course of
conduct with a client and may counsel or assist a client to make a
good faith effort to determine the validity, scope, meaning or
application of the law.
That's just a suggested ethical standard, but most countries will have something along those lines.
Note also that in the US there is also a "Crime-Fraud" exception to attorney-client confidentiality. If a lawyer assists a client in carrying out a criminal or fraudulent scheme then their communications are no longer privileged and can be subpoenaed and introduced as evidence in court.