This is the American expression, and, according to the record, we and our grandsires before us and their sires or grandsires also used it when expressing mastership or authority.
The original analogy was, undoubtedly, the rooster, who is cock of the walk in the hen yard.
It is very likely, however, that the American saying was strongly influenced by the far older British saying which conveys the same meaning, “to rule the roast.” And this usage goes back at least to the fifteenth century, “What so euer ye brage or boste, My mayster yet shall reule the roste.”
The origin of the British expression has caused a great deal of speculation. The usual assumption is that it alluded to the lord of the manor who presided over the roast of meat at the table; but I find myself in agreement with the minority in the belief that the actual ancient word was that which we pronounce “roost” today.
Formerly, along with door, floor, brooch, other words now spelled with a double “o” were also pronounced with a long “o,” and there is excellent reason to suppose that “roost” was one of them.
This, together with the fact that modern “roast” was formerly sometimes spelled “roost,” makes it fairly convincing to me that the ancient intent was in full accord with the modern American expression, or that the old-time master who exercised full authority, along with the cock of the barnyard, actually “ruled the roost.”