Well...melanin and xanthophyll, of course!
In most cases, black spots on a duck's bill and legs are simply melanin skin pigment, which is not harmful in any way. The pigment is usually already present, but covered with xanthophyll--a yellow-colored pigment absorbed from feeds containing corn, alfalfa, and other feed ingredients. Xanthophyll is also found naturally in the leaves of green plants, egg yolks, fat, and skin. In mature breeder ducks, after they have been laying eggs for awhile, more xanthophyll is absorbed by the egg yolk than the duck can consume in her feed. When this happens, her bill and legs start showing melanin skin pigment due to the bleaching or fading of the xanthophylls.
Less common causes of duck bill and leg discoloration include injury, infection, dietary deficiency, and possibly, fungus. Take your bird to an avian veterinarian to get an authoritative diagnosis and treatment plan if you are concerned that the discoloration is more than just "skin deep."