Welcome, Jray. I can't give you the formal evolution of the military chain of command, but you can probably blame it on a few thousand years of trial and error.
In any group of people, one generally emerges as the leader by virtue of superior skills, charisma, or simple force of personality. The earliest military leaders emerged this way, and later systems codified the natural emergence to a greater or lesser extent. The bottom line is that in a combat environment, an organization with a single strong leader is more likely to reach decisions quickly than one with multiple leaders, and therefore more likely to succeed. Military theorists and historians call this Unity of Command.
As to the development of a chain of command, a human leader can manage at most four or five direct subordinates simultaneously, so subordinate leaders emerge at intermediate levels to make the job easier. That way, a commander deals not with a hundred or a thousand subordinates, but a handful of lower-level leaders. Unity of command at each level, and no commander is overwhelmed by the number of moving parts he has to control. Like the overall unit leadership, armies have codified this natural tendency to a greater or lesser extent.
So to make a long answer longer, the military chain of command structure has emerged because it is 1) the formal expression of a natural human tendency, and 2) the most efficient way we know to run a military organization. Is it perfect? Not by a long shot. But the history of human conflict shows us it works, and until someone figures out a better system it's what we will have.
Clear as mud? I thought so.
HN