Humans and gorillas are descended from a common ancestor. Because there is only one difference in amino acids in the hemoglobin of present day humans and gorillas, it is likely that the ancestor had identical hemoglobin to one or the other. Evolution happens by natural selection of one genotype over another. The differences between individuals of a species occur by mutations of the genes. The short answer to your question is that the difference was caused by a random mutation of the DNA of the common ancestor, which was then carried down to present day humans and gorillas.