The gastric juices helps in the digestion of the food but the pH of the these juices can affect the inner lining of the stomach if there would have no mucus secretion from the epithelial cells.
The low pH would have been destroyed the lining of stomach and this can result in the causing ulcer. To prevent this the walls of the stomach has epithelial cells that secretes sticky secretion known as mucus.