Lions have been associated with royalty for thousands of years, just consider the sphinx.
The first record of Lion as king seems to be in Aesop's fables from about the sixth century B.C. King Lion is referred to in "The Fox, The Cock, and The Dog" Lion King of Beasts is referred to in "The Lion in Love" and in "The Lion's Share" Lion Lord of the Beasts is referred to in "The Lion the Fox and The Beasts". I'm probably forgetting some other references.
So the Lion as a King of Animals has been around since at least the 6th century B.C.
As for the reference to "King of the Jungle" this probably has it's roots in 17th and 18th century notions of Africa as a land of Jungles.
According to this article (apologies if you don't read French), lions were associated with kingliness in ancient Mesopotamia. It was referred to as the "king of the beasts" in the Physiologus (c. 2nd century CE) and repeatedly in Aesop.
King of the "jungle" specifically is tougher, but it probably stems from the superficial 19th century view of Africa. e.g. "Africa has jungles; Africa has lions; the Lion is king of the beasts; therefore, the lion is the king of the jungle." Yes, this is based on a misunderstanding, but it has been continually reinforced since the Tarzan stories.
If I may OP, I'd like to add onto your question: Why, even after researching the large species of African wildlife, did we decide lions were king instead of, say, gorillas? Or some other alpha predator? Why not an elephant?