Flux consists of four major components.
- Activators - chemicals dissolving the metal oxides.
- Vehicles - high-temperature tolerant chemicals in the form of liquids or solids with a suitable melting point. They act as an oxygen barrier to protect the hot metal surface against oxidation, to dissolve the reaction products of activators and oxides and carry them away from the metal surface, and to aid in heat transfer. A common "vehicle" in electronics soldering is rosin.
- Solvents - added to aid in the processing and deposition of the solder joint. Incomplete solvent removal leads to boiling off and spattering of solder particles or molten solder.
- Additives - Additives can be corrosion inhibitors, stabilizers, antioxidants, thickeners, and dyes.
Short answer: Flux removes oxidation, aids in heat transfer, cleans and prepares the joint to accept the solder, and promotes even solder flow.
Many various fluxes contain metal halides which are metals combined with halogens. Halogens are a group in the periodic table consisting of five chemically related elements: fluorine (F), chlorine (Cl), bromine (Br), iodine (I), and astatine (At). These halides are the activators. Because flux has a low melting point it will liquefy before solder solidifies. Metal halides often promote corrosion which will help aid in the dissolution of the oxide allowing the contaminate to flow away from the joint. Then the solder will flow into the joint forming a strong bond that actually fuses with the metals involved. Which is why metals like lead and tin are used to solder metals like copper because they form a bond with the metal that creates a thin layer of alloy metals. I do not believe there are any "products" from this reaction. There was a saying in Chemistry I learned once "like dissolves like". It takes corrosion to remove it. However, heavy corrosion will not remove from the metal by just using solder flux which is very mild and not acidic as flux used in copper tube welding.
I wasn't able to research "voids" in the solder. In my experience that is due to soldering with extremely high temperatures. Lead melting point is about 621 degrees Fahrenheit. If your iron is too hot it can super heat the lead and cause it to "explode" or pop off the joint. Perhaps this is a cause of voids. Also, if the material being soldered is very dirty it could cause contaminates to be trapped under the solder that the solvents in the flux are unable to clean away. Which, as mentioned above, can cause spattering and boiling off of solder particles which could cause the "voids".