An action may be unethical but not illegal.
That statement is true.
For example, a company COULD decide to hire ONLY from a certain gender or racial group.
This action is technically not Illegal in any way but it certainly cannot be considered as ethical.