Wikipedia has more. This is just the start:
In French history, “lieutenant du roi” was a title borne by the officer sent with military powers to represent the king in certain provinces. A lieutenant du roi was sometimes known as a lieutenant general to distinguish him from lieutenants subordinate to mere captains. The sergeant acting as staff officer to the captain general was known as the sergeant-major general. This was eventually shortened to major general, while captain general was shortened to simply general. This is the reason why a major outranks a lieutenant, but a lieutenant general outranks a major general.