Welding flux is a combination of carbonate and silicate materials used in welding processes to shield the weld from atmospheric gases. When the heat of the weld zone reaches the flux, the flux melts and outgasses. The gases produced push the atmospheric gas back, preventing oxidation (and reactions with nitrogen).
The melted flux covers the molten metal in the weld zone. Flux materials are chosen so that the density of the melted flux / slag is lower than that of the metal being welded, so that the flux floats to the top of the weld puddle and leaves pure or nearly pure metal to solidify below.
Flux materials may also contribute to metal behavior in the molten metal, with physical or chemical alterations to the molten metal.
The flux cover also helps thermally insulate the weld and reduce the cooling rate.