Before diving into the history of haiku, there's a precursor step. The Japanese language is broken up into symbols that are what we'd typically write in English as digraphs. Most sounds in Japanese consists of a consonant and a vowel combined. To illustrate this, have a haiku:
ふ る い け や
(fu ru i ke ya)
か わ ず と び こ む
(ka wa zu to bi ko mu)
み ず の お と
(mi zu no o to)
5 symbols, 7 symbols, 5 symbols. So when we talk about "syllables," this meant something much more specific in Japanese. And this happened to be something of importance to Japanese poetry. Of course, this haiku is easier to read if we split it up by words:
ふる いけ や / かわず とびこむ / みず の おと
furu ike ya / kawazu tobikomu / mizu no oto
Ah, the ancient pond / as a frog takes the plunge / the sound of water.
This all is a slight simplification, though. Japanese has digraphs, like きょ, which we write as trigraphs in English: kyo, as in Kyoto. But these still count as one phonetic unit (called "on" in Japanese), and that's what notation like "5-7-5" counts. (Haiku tends to be written with kanji, anyway, which changes the raw symbol count. But writing it like I did above serves to show clearly where the on are.)
With the poetic basis for understanding the structure of the haiku out of the way, let's talk history.
The origins of haiku lie in religious practices, Shinto and Buddhist alike, as well as general poetic practices and culture. Songs frequently followed a form called waka. This form essentially boiled down to a combination of two other forms: choka, which follows 5-7-5-7...5-7-7, and sedoka, which follows 5-7-7-5-7-7. This precursor to haiku was just a culturally ingrained pattern - not unlike the four chord song [language warning]. It's just a shared recognizable pattern for music and poetry. And many forms for poetry diverged from there.
The form called tanka is a specific form of waka, and is so frequently used interchangeably that it has muddied the meaning of waka. However, the tanka form is a refinement and restriction on the general pattern of waka: it follows the form 5-7-5-7-7 specifically. This form is often considered the precursor to what we now call haiku.
Many poets laid their hands on shaping this form in between tanka and haiku. Enumerating them all is beyond the scope of this answer. Significant contributors were Matsunaga Teitoku, a wandering poet who wrote a plethora of prose and poetry, and Issa, who wrote often on the state of Japanese society.
But the direct precursor to haiku is Masaoka Shiki, who took the form that had evolved over time, and focused in on 5-7-5. He is the person who gave it the name "haiku," largely under the banner of tanka reform. He wrote well over 25,000 haiku. It is largely the popularization of Shiki's writings in Japan that led to the prominence of the form elsewhere in the world. His commentary presented it as a simpler, cleaner aesthetic - its compressed nature, he wrote, could sketch life and reality much more easily than any more complex form could. This is a strong appeal to principles in Japanese culture, and is the ultimate aesthetic choice backing haiku.
It was then spread through popular poets and poetry to English-speaking countries - except instead of Japanese phonetic units, they naturally counted in English syllables. The popularization of haiku spread from there into the 1950s, giving us the form we know it in today.