I have read that the the modern 'an' derives from the Old English 'ān', which is also the source of 'one'. So I guess I can see how "one hour; one apple" could work, but that doesn't explain 'why'. What is the function of having one indefinite article for words starting with consonant sounds, and another of words starting with vowel sounds? I did some searching around but the entries I found cited when you use should 'a' vs 'an' but not the why.
Linguistic changes, including sound changes, come naturally. There’s no function for having two forms of the indefinite article. This is probably not the answer you’re looking for, but it is so because it is so.
As for the “why”, linguists are also not 100% sure, but many point to the principle of least effort. One of the most common effects of this principle is cluster reduction: perhaps for most people it’s easier to pronounce a man than an man, whereas an hour doesn’t contain a cluster to be reduced.
There are not two different indefinite articles. Both a and an have the same origin; but before a consonant the /n/ has been lost — much like the /v/ in of in ordinary speech.