Hydrochloric acid is an acid in our stomach which helps in digestion.
Too much of acid in the stomach causes acidity. To relieve acidity, we take an antacid such as milk of magnesia, which contains magnesium hydroxide.
It neutralises the effect of excessive acid as it is basic in nature.