It is marked illegal because everytime you pick up something in space, it is marked as "Stolen". So be prepared to go "silent running" if the station where you are going to drop the cargo has security forces around it. Otherwise they will scan you and you'll have to pay a fine. Probably more than the mission is worth.
So, when exiting supercruise at the destination station, if it is an Orbis or large station (outposts are safe, no security there), keep your distance to 6 km or above and find the entrance. Check your heat, let it set at ~50%. Request docking when in front of the entrance (at 6 km) and start going forwards. When you can see the security forces on scanner and on the contact list, they can also see you. Now you turn on "silent running". This will keep you below radar, so they won't scan you. But it will build up heat pretty fast. Make it quick through the entrance, and once inside turn off Silent running and vent out that heat. You can go up to 150% before taking damage. Don't use boost when in silent mode, that will add too much heat to your ships interior. Dock and complete mission.
The same goes for carrying all types of stolen cargo, so keep an eye on your hold and try to check which commodities are illegal in the systems you are visiting. Otherwise there will be nasty surprises.
/Trash