Gastric acid aids in digestion by denaturing proteins, making them more accessible to digestive enzymes such as pepsin. It also provides an acidic environment that is optimal for enzyme activity and helps in the absorption of certain minerals like calcium and iron. Additionally, gastric acid serves as a barrier against pathogens ingested with food.