Many times when a metal is being soldered, it oxidizes, making a layer of metal oxide that does not hold solder. Flux is added to react with the metal oxide and turn it back into the metal again. That helps the solder connect to the metal. Rosin is a common flux. Some electronics makers use fluxes that can be washed away with water. Some solders have a flux core, where the flux is inside the solder.