What is the primary function of a buffer solution used in analytical chemistry?