Apple’s cables are unique because most other electronics manufacturers use only black cords. Black doesn’t show dirt, I guess. But white doesn’t have to either.
If you have a discoloured white cable, grab some isopropyl alcohol (I used 99% USP) and a kleenex. Find a horizontal workspace that does not have a wood surface. Alcohol will bleach wood! Ball up the end of the kleenex and dampen it with alcohol, and lay out the cord on a horizontal surface. Starting with just a short section, rub the cord thoroughly with the kleenex until the cord turns white. That’s all there is to it!
Be careful not to get the ends of the cord and connectors excessively wet, or you will cause damage. Also, let the cable dry completely before attempting to use it. Don’t use alcohol to clean your device.