There are different types of surfactants;
nonionic, cationic, anionic, and zwitterionic (amphoteric) types.
Their charge or absence thereof dictates several effects.
Nonionic detergents like many polyoxyethylene derivatives work well with high ion concentrations (especially calcium) and may complex potassium.
The polyoxyethylene part is not readily degraded but serves as a moistener in the soil (it maintains a fine film of water on the soil particles).
They are relatively harmless and gentle with the plants and micro-organisms.
Many are often pretty active (that means the critical micelle concentration or CMC is low) and one does not need much for a wetting effect (like Tween-20); others are not soluble in water like sorbitane esters (e.g. Span-80).
Polyoxyethylene-fatty acid conjugates (i.e. Brij) are known as good penetrators but like Spans may stick too well to the plants cuticle and hence reduce its protective functions for a prolonged time.
Another group of nonionic detergents are the glycoside alkyl ethers and esters; best known for ‘no tears’ baby shampoos.
They are very mild and biodegradable and have a range of beneficial effects but to my knowledge are seldom available in pure form (apart form expensive research quality).
The esters are way faster degraded (to ‘sugar’ and ‘fat’) than the ethers and should be preferred when applied to plants.
The last common group are alkylphenoxypolyethylenglycole derivatives like Triton X-100; are probably as terrible as the name sounds, don’t suggest you use them on plants because of their lacking biodegradability and the aromatic part (may cause problems when smoked).
Cationic detergents are also known as invert soaps.
They contain a quaternary ammonium moiety rendering them less biodegradable and often highly active against micro-organisms like soil dwelling helpers.
In my opinion they are a no-go on plants but may be used in sanitizing a grow room (e.g. floor).
Anionic detergents are the old standard soaps and detergents (and there are also newer ones.
Traditional soap (free fatty acids) and cheap dishwashing agents (SDS aka sodium dodecyl sulfate) belong to this group.
Free fatty acids are quickly biodegraded but they are often not very strong and their characteristics highly depend on the counter ion; they are rather obsolete apart from shaving cream and natural soft soap (often used in organic farming as a pesticide!).
SDS and the more recently employed sodium laureth sulfate are amongst the strongest detergents (strong like with duct tape, a drop of soap often does the trick, but they may damage the plants and beneficial micro-organisms along the way.
They should not be used together with higher amounts of minerals (especially calcium) because of precipitation but due to the low quantities necessary may be used now and then as a wetting agent without obvious side effects.
Zwitterionic detergents are also pretty efficient but often less aggressive than anionic ones.
Many are semi-natural (nature identical) like betains (used as foam booster) or even completely natural like phospholipids (lecithin).
Mainly lecithin is of interest; it is highly efficient and can bind enormous quantities of oil in water (see mayonnaise) but even though remains very gentle to humans and plants.
It is also able to complex calcium without losing its activity.
Obviously, it is quickly biodegradable (a source of choline, inositol, and phosphate), concidered to be edible, but unfortunately not that stable (turns rancid).
Lecithin is great stuff but depending on the quality may need to be degreased with acetone prior to use and it may be tricky to form sufficiently stable preparations with kitchen chemistry.