Although not strictly required, flux really helps the soldering process by "wetting" or reducing the surface tension of the solder so it will flow easily into the joint. They can also chemically remove impurities and prevent the metal from oxidizing as it is heated by the iron. Some fluxes (non-acid or "R" type) will act as a protectant after the soldering is finished to reduce corrosion, but others (acid core aka "Activated" or "RMA" and especially "RA" types) actually etch the metal and will eat it away if not removed by cleaning with water or isopropyl alcohol. "No clean" fluxes are non-corrosive, and non-conductive, but may not perform as well and leave behind unsightly resedue which is usually still cleaned away.
Flux is probably most critical when soldering Surface Mount Devices, where it is applied by hand with a very fine dropper or pen, or as part of a solder paste which also contains tiny balls of solder. Solder paste can be applied manually, but is most often applied through a metal stencil or solder mask in a process much like silkscreen printing.
For standard electronics soldering, rosin (made from purified select pine tree sap) disolved in an evaporative base such as isopropyl alcohol has been the standard.
See also: