Well, that's not entirely true, as Lieutenant shows up in both domains as well, but it's an issue of the rank being based off a position rather than a title. The Captain is the man in charge on the spot. This is why captains on land rank equivalently lower than their naval counterparts. Lieutenants, lower than Captains, are their assistants, Lieutenant literally translates as "placeholder". So when the captain is away, his lieutenant takes over. Note that in earlier times, ere were fewer naval ranks than there are now, so while a ship captain's "first lieutenant" (meaning the XO/2IC) may have the position of first lieutenant, his rank, as opposed to his position, may be something else, such as Commander. (Of course, a Captain (position) doesn't have to be a Captin (rank), it can be an LTCdr for example.
Speaking specifically for the Royal Navy of first England then Britain, traditional military titles entered the naval sphere during the gradual shift from privately-owned vessels summoned into service during times of war to an actual standing, professional navy. Throughout the period from the Norman Conquest up to roughly the time of Henry VIII and Elizabeth I, England relied on civilian ships for transportation, supplies, and (rather rarely during this period) combat. Soldiers would sometimes be assigned to these vessels and they would be commanded by a military officer, while the functions of the ship were run by the ship's master. These officers also represented the royal interest on the ship and in that respect had some degree of command, but anything nautical was deferred to the sailors.
When a professional navy began to develop it was still necessary to draw nautical expertise from civilian sailors, and for some time this distinction between professional sailors and military leaders lingered. Even in the mid-1600s, when the Royal Navy really began to grow into a large institution, there were notable examples of army leaders being appointed to command ships and fleets, with the expectation that their military skills would translate to combat at sea while the sailors handled the details of, well, sailing.
During this period in the 1600s there was still some question of who truly commanded the ship: the sailing master or the military captain? By the late 1600s, when the Royal Navy had finally coalesced into a recognizable form, the notion had developed that the captain was truly in command, but also that the captain and other military officers should know how to operate a ship at sea. Part of the process that led to this was the idea that ships should be commanded by gentlemen, not common masters. The master remained as the senior warrant officer on board the ship, serving as an experienced sailor (especially in navigation) who could provide his expertise and train the "young gentlemen" who would become the next generation of lieutenants and captains. It was still possible for someone to rise through the warrant ranks and become a captain (or even admiral), but it was rare.
So, basically, the naval warrant ranks represent the original hierarchy of sailing vessels and the military ranks were imposed onto this system.
Sources: Safeguard of the Sea and (primarily) Command of the Ocean, both by N.A.M. Rodgers.