Water is so good at dissolving various ionic compounds that it almost always bears some dissolved minerals. Under the right conditions, calcium and magnesium ions in the water may combine with other ions to form insoluble precipitates called scale. In some circumstances, acids such as hydrochloric acid may be the most appropriate treatment.
A more acidic pH works to keep calcium and magnesium in solution by protonating (giving hydrogen ions to) ions such as carbonate and phosphate. These ions might otherwise combine with the calcium and magnesium ions to form scale. A more acidic pH helps to dissolve the scale for much the same reason; when calcium carbonate or phosphate dissolve in an acidic solution, the phosphate or carbonate ions quickly acquire a proton from the solution, which by definition (being an acidic solution) has a high concentration of hydrogen ions. This shifts the equilibrium between the solid calcium carbonate or phosphate and the calcium in solution -- an application of a chemistry concept called Le Chatelier's principle.
Hydrochloric acid is a much stronger acid than phosphoric acid. This means that in solution, virtually all the hydrochloric acid molecules will have donated a hydrogen ion to a water molecule, while in a phosphoric acid solution, only a fraction of the phosphoric acid molecules have given up their hydrogen ions. Hydrochloric acid will therefore decrease the pH of the solution more dramatically, so it will have a greater effect on the scale than the phosphoric acid.
Phosphoric acid has the molecular formula H3PO4. If it loses all three protons -- as would happen in an alkaline solution -- the remaining ion is the phosphate ion, PO4 with a -3 charge. Phosphate ions can combine with calcium ions to form calcium phosphate, a highly insoluble compound. Because it can increase phosphate concentration and is a weaker acid, phosphoric acid is a less effective scale-removing agent than hydrochloric acid. Hydrochloric acid or sulfuric acid are more commonly used for industrial scale removal.
Corrosion and Hazards
Hydrochloric acid solutions are more corrosive than phosphoric acid solutions of similar concentration. This means they may be more likely to damage metals that are vulnerable to corrosion, so if you are dealing with surfaces that could be corroded easily, you should choose another treatment method besides acid. Moreover, hydrochloric acid is a hazardous chemical. If spilled on your skin or eyes, hydrochloric acid could cause serious injury, and the vapors from concentrated hydrochloric acid are potentially dangerous as well. If you are concerned about your ability to work safely with this chemical, you may want to consult a professional for advice on how best to resolve your scale problem.