I understand it has to do with the marbling of the meat. Does the grading system apply to the entire cow, as in any cut from this cow is considered prime/choice/select? Or is it done by the portion of meat cut; could the same cow produce both prime meat and sub-select meat? And who came up with prime-choice-select instead of a simple letter grading system?
The grade is by whole carcass.
History of beef grading in the US
A thorough introduction to the specific methods behind grading is found here.
USDA beef grading has two primary components: a "quality" grade and a "yield" grade. Both are done for a whole carcass, so all cuts from that carcass will have the same declared grade. Most American consumers only see the "quality" grade at retail stores. More detail can be found at the links.
In sum, "quality" grading for retail cuts -- usually Prime, Choice, and Select -- is ONLY a reflection of marbling (i.e., fat distributed through lean muscle), which tends to influence tenderness and flavor in fast-cooking methods. Basically, you should use a quality grade to help determine a good steak or perhaps a prime rib roast. That's where the rating system is most relevant for consumers.
Because "quality" is only based on marbling, different breeds of cattle and feeding regimens may result in incompatible "quality" estimates. The most common example today is probably the rise in grass-fed and free-range cattle. These tend to produce a much smaller amount of Prime graded carcasses, since they tend to be leaner overall than grain-fed cattle and/or those in confined feedlots.
(Note that studies have shown the vast majority of American consumers do not know what the rating system is about, with more than half thinking that high "quality" ratings correspond to leaner beef, when the opposite is true.)
USDA beef "quality" grades only measure two things:
That's it. Beef grading does not consider flavor, texture (except as a minor contribution toward determining age), cattle breed, living or slaughtering conditions, or any other factors that consumers might associate with "quality." It also does not consider any individual parts or cuts of the carcass, which could vary in significant ways (e.g., in different cattle breeds or depending on exercise, feed, and other "lifestyle" elements for the cow).
Age grading is only relevant in determining whether the cow is less than or greater than 42 months of (physiological) age. If less than 42 months of age, the carcass may be graded in one of the categories (Prime, Choice, Select, or Standard) which tend to be seen at retail sale. Meat from those graded at more than 42 months of age rarely end up at retail markets (since they can only be graded Commercial, Utility, Cutter, or Canner grades, and mostly end up in processed products). So age grading is basically irrelevant for the typical American consumer when choosing a retail cut.
Thus, the only thing a retail "quality" grade represents is marbling between the 12th and 13th ribs (which is roughly indicative of marbling through much of the beef).
For those retail cuts, the grading may fall into four categories:
There is often more detail given in grading, such as a "Choice+" or "Choice-" to indicate more detail in marbling, but retail stores rarely present that information.
Sometimes Commercial grade beef appears at retail, which may have variable marbling, but the carcass is greater than 42 months of age. When sold at retail (if at all), it will not generally be advertised with this grading, again perhaps appearing as a "store brand." As mentioned above, older meat also has lower grades that basically never appear at retail. Moreover, beef grading is voluntary, so retailers have no obligation to advertise grades.
It's also important to note that some retailers will use similar terminology that can appropriate these adjectives in a variety of ways to make the meat sound like it's a higher grade. (The USDA officially approves of and even gives examples of this practice.) For example, a store brand might label its products "Nation's Choice" or "Lean-Choice" (for leaner meat) or "Prime Rib of Beef," even if the actual meat is graded lower, such as Select grade. Consumers should look for the official "USDA Shield" and grading symbol, which is the main way to determine whether the nomenclature actually refers to quality grading.
Carcasses are also graded within the USDA system by their expected total yield of trimmed retail cuts, based mostly on amount of surface fat. The system is numerical, from 1 to 5, with 1 having the most yield (and lowest amount of trimmable fat) and 5 having the least yield (most external fat).
Yield grades are mostly used among meat packers and retailers to get a sense of how much meat they can extract from each carcass. Consumers very rarely see these grades.
History of USDA Grading
Details can be found here.
The USDA beef grading system was gradually developed in the early 1900s. The modern system was basically adopted in 1926 and implemented in 1927. Originally, the intention was to standardize grading across the nation. One effect was to allow local and regional meat producers to compete with national packers -- by having a term like Prime or Choice to sell at retail, they could compete against the "house brands" of familiar national packers. (Originally, Select grade was labeled as Good; this was changed in 1987 in response to consumer perception studies. Various other alterations to the system over the years; see the link.)
The large national meat packers fought this grading system and developed their own internal grading systems to compete with the USDA, but these alternative systems disappeared within a few decades. Nowadays, of course, large-scale meat packers are the norm in the US again.