Background: I am aware, largely from reading historical fiction such as Hornblower, that English ships in the Napoleonic period, and possibly earlier and later periods, had a responsible officer on board called the sailing master, who as I understand it was responsible for advising the captain in maneuvering and navigating the ship and deciding how to set the sails. I believe this was a warrant officer rather than a commissioned officer. My questions pertain to the nature and origin of the rank, how sailing masters were trained and promoted, and how they compared to commissioned officers such as lieutenants.
How did the position of sailing master originate? Was this a legacy of a pre-Napoleonic period when ships tended to be commanded by army officers or well-connected gentlemen with little in the way of naval training and experience?
Is the position of "sailing master" related to the Napoleonic rank of "master and commander" in any way besides coincidence of names?
How did one become a sailing master? Was one promoted from an enlisted rank? Was there perhaps prior service as an officer on civilian ships involved? What is the relationship between master's mates, midshipmen, and the sailing master?
How did a sailing master compare to a commissioned officer like a Lieutenant? What was the relative pay? Did sailing masters serve watches? Could a sailing master command a ship or prize under any circumstances?
Did the position of sailing master continue into the age of steam? If so, what were the responsibilities of the position?
I can answer parts 3 and 4 of your question. A sailing master on a vessel of the British Navy was usually someone who had been a good midshipman, with exceptional skill in navigation, but whom either did not have the connections to feel confident in receiving a commission or saw a more quickly promising future in pursuing a warrant commission as a sailing master.
A master's mate was a midshipman who had been rated master's mate based on his skill in mathematics and navigation. Being rated master's mate was a promising step towards passing for lieutenant, as it showed the examining officers that the young man had solid navigational experience.
A sailing master during the age of sail had the official status of being equal to commissioned lieutenants, though technically the least among the lieutenants on board. In practice, he would typically be respected as a social equal of the lieutenants.
A sailing master was expected to be capable of serving a watch. In practice, he would only stand a watch on a smaller vessel with only one or two lieutenants, or certainly on a craft commanded by a lieutenant (like some troop or store ships). He might also be called on to do this if a vessel suffered heavy losses due to disease or combat.
A sailing master could command a prize if a commissioned commander asked him to. Even midshipmen could be given this assignment. Whether a sailing master could take command of a King's ship if all of the commissioned officers were killed or incapacitated, I am not certain.
Sailing masters were re-imagined in the 1860's. They were no longer warrant officers but a special type of lieutenant.