It is illegal to run a traffic light or speed even though it is ethical if someone's life depended on it.. like if you had to rush them to the hospital.
It is illegal to work "off the clock" (voluntarily or not) if you are an hourly employee even though it might be the ethical thing to do in order to help the company progress forward.
It is illegal to let someone else use your perscription athsma inhaler even though it might be the ethical thing to do if they are having an attack.
It is illegal to lease a car or an apartment in your name for someone else who otherwise would not qualify but it is an ethical thing to do if it is going to help them succeed in life.
It is legal to mislead people when selling a product or service provided that you did not directly lie about it even though it is unethical to make them believe that what you are offering is not what you represented it to be.
It is perfectly legal to operate multi-level marketing and pyramid-type operations even though it is unethical to promise people that they will make $40,000 a week.
It is perfectly legal to initiate a hostile takeover on a small business yet it is unethical to forcibly acquire what someone had worked so hard to build.
It is perfectly legal to "pump & dump" stocks even though it is unethical to con people out of their money.