This phrase appeared occasionally in non-metaphorical use1 before the twentieth century, but took off in popularity throughout the 1920s and 30s:
—Google Ngram, "make the grade", case insensitive
Looking at early examples in Google Books, I think the "climb the hill" version is more likely, but I believe it took off in popularity not just from the train usage but also from individuals' personal experience trying to get buggies and, crucially to the time period of the phrase's largest gain in usage, from automobiles. From a 1917 publication (bolding mine):
[After describing the health hazards of modern living:] The human machine is spoiled in the making. When you start to take the grade in it your motor heats, your spark plug misses, your carburetor gums and won't work, you blow out a tire, then you are shunted to the side of the road, or you tumble back to the level from which you started and there you remain—couldn't make the grade; you are an old worn-out, broken-down wreck with a sign pinned to you—"For Sale, Cheap"—just like the wreckage of wagons and buggies that you see in blacksmith shops all over the country.
A wave of pity sweeps over me every time I see a derelict, human or machine—"could not make the grade" is stamped all over such relics.
. . .
Ninety per cent of men and women, normal in mind and healthy in body, can make the grade, can climb the hills if they are properly trained in childhood, and are taught the great laws of life.
—Charles Virgil Mosby, Making the Grade, 1917
This early adopter of the metaphor was clearly thinking in terms of hill climbing, rather than grades of wood (another early literal use of the term). It isn't clear to me whether the signs saying "could not make the grade" on wrecks were an actual phenomenon or just the author's imagining, but if it was an actual practice to put such signs on wrecks this would be a very strong, everyday visual reinforcement of the metaphor, even for non-drivers.2
Another early example of make the grade in the hill sense comes from an account of a 1920 Connecticut Republican gubernatorial primary convention3:
The Roraback machine, after skipping and skidding through the night, failed to make the grade today and J. Henry Roraback, boss of Connecticut the last eight years, was visibly nervous as he sat on the platform behind the Permanent Chairman, United States Senator George P. McLean, watching the delegates whom he once completely controlled, break away and follow their own inclinations.
—"Lake for Governor of Connecticut", New York Times, Special to The New York Times, Sept. 10, 1920.)
Here we have an extended metaphor equating a party's political "machine" failing to nominate a candidate to a train that tries to climb a steep grade, only to fail and see its cars (here, delegates) "break away". The hill metaphor is complete with the double meaning of "inclination": "a person's natural tendency or urge to act or feel in a particular way" and simultaneously "the fact or degree of sloping" (Oxford Dictionaries).
One final clue that the "hill" use may be the primary origin: this usage is consistent with the use of unmodified "grade". That is, a vehicle itself does or does not "make the grade", but most early examples of the literal use of making the grade in reference to accepted standards specify a grade of something. For example:
I am not condemning hand separators, but we cannot make the grade of butter from the hand separator cream; that is the trouble, as far as the machine is concerned, the machine is all right.
—Proceedings of the Tenth Annual Meeting of the Pennsylvania Dairy Union, January 14-16, 1908
They open up the throttle and give the train more speed in order to make the grade.
—Metz v. C. & W. C. Ry. Co., 125 S.C. 1, 1923 (Reports of Cases Heard and Determined by the Supreme Court of South Carolina, Volume 125); snippet view
1 Most of the earliest literal examples are actually about physically "making" a grade, i.e. earth-moving projects in road or railroad building to smooth, increase, or decrease slopes. A few others refer to climbing hills, and a few show up as part of a larger clause/sentence or straddling two clauses/sentences about an accepted standard of something, e.g. a proposal for the grading of lumber to "Make the grade of No. 3 Common 33⅓ per cent and better clear instead of 25 per cent and better sound." ("Bell of Hardwood Institute on Low Grade Lumber Impasse", The Lumber Manufacturer and Dealer Vol. 20, December 8, 1922)
2 It is also possible that this book itself or its author had some influence in the adoption of the metaphorical use of the phrase. I haven't been able to find out how successful the book was in its day, but it is still available on Amazon as a "classic reprint"; I don't know how these "classics" are selected, but there is at least a possibility that the book had a significant readership at one time. Moreover, Mosby was the founder of the eponymous academic publisher, which still exists as an Elsevier imprint (see Wikipedia article "Mosby (imprint)). I can imagine that a favorite metaphor of the founder of a publishing house might make it into the books of some of that publisher's books, and could trickle out from there.
3 This database is paywalled; check with your local library for access to New York Times historical issues (most US libraries probably have access).