my guess would be that human languages prefer a state where a good measure of redundancy can be found in most utterances, as this helps listeners to understand correctly, reassure themselves they did, correct errors (due to the speaker's sloppyness, ambient noise or whatever) or ask for repetition when unsure: that is, speech has a built-in 'error-correction code' as it were. this explains why probably no natural language uses all of its phonemes in all possible combinations—there are always phonotactical restrictions.
vowel harmony is such a phonotactical restriction, but one that (at least seemingly, in strictly segmental phonology) works at a distance. for example, in Turkish, there are two dimensions involved in VH, [front] and [round]:
Unrounded Rounded Unrounded Rounded
High i ü ı u
Low e ö a o
in Turkish, some suffixes may have four different (surface) forms, e.g. Türkiye'dir "it is Turkey", kapıdır "it is the door", but gündür "it is day", paltodur "it is the coat" (taken from Wikipedia).
note that this analysis suggests that the way the vowels partake in VH is a so-called natural categorization, as the divisions presented here neatly follow articulatory and auditory categories (i.e. positioning of speech organs and spectral features) that are well attested to be phonotactical factors of some sort in lots and lots of languages.
because of this naturalness of vowel harmony, both speaker and listener know that if you meant to say 'it is day', then 'it is' must be 'dür', not 'dur' or 'dir' or anything. this is convenient for the speaker as they can perform less gestures (they can be lazy and just leave their lips rounded for the entire duration of 'gündür'), and useful for the listener: if they believe to just have heard, say, 'gündir' or 'gündur', then surely they must have heard wrong, the speaker is at fault (happens), or maybe 'it is day' is not the intended meaning of the utterance.
note that i have suggested a suprasegmental reasoning here, assuming that the 'nd' in 'gündür' is indeed articulated with lips rounded. that may or may not be the case in the language discussed here, but it would still make phonological sense to adopt a Firthian stance here and assign [round]ness and [front]ness to all of 'gündür', not only the two vowels that are separated by consonants.
in fact, some languages do seem to have restrictions that can hardly be explained by a static suprasegmental feature extending over syllables or words; for example, in Mandarin / Putonghua / Modern Standard Chinese, (1) each syllable can only have one /i/ and one /u/; (2) /i/ and /u/ always have a more a less audible vowel in between them (i.e. the syllable nucleus, so /i/ and /u/ always end up in the periphery of the syllable unless when they come alone); (3) /ü/ functions as a combination of /i/ and /u/ in that syllables that have an /ü/ can not have another /i/ or /u/. one effect of these rules is that in Chinese, you have /uai/ (pinyin: wai) 'only' and /iau/ 'want', but no */uau/ and no /iai/ (in fact, the latter syllable vanished from the mainland standard within the 20th century, although it is still used in Taiwan, so we can see the rule is not a 100% one but does appear to have some force).
now in this analysis it does look like the restrictions on /u, i/ do work on a distance, as an initial /i/ has to 'skip the a' to have any effect on the terminal vowel. this is not commonly understood as a case of vowel harmony, but in the broader picture, it is not fundamentally different from the restrictions on vowel distribution in Turkish.