Christine Ammer, The Facts on File Book of Clichés, second edition (2006), offers this entry:
square meal, a A substantial and nourishing repast. A mid-nineteenth century Americanism, the term appears in humorist Stephen Leacock's Literary Lapses (1910): "Any two meals at a boarding house are together less than two square meals."
One astute 19th-century commenter, Maximilian Schele de Vere, Americanisms: The English of the New World (1872) has this to say about "square" (squarely) and "square meal" (glancingly):
Square, either as an adjective qualifying a noun, as "a square trade," or as a phrase, on the square, refers to the open, fair character of a transaction. In either case the metaphor is borrowed from the Masonic emblem, the square being the symbol of evenness and rectitude. Thus all squares is used in Pickwick Papers, p. 434. "It ain't no square game. They've jest put up the keerds on the chap from the start." (F. B. Harte, Preface to Luck of Roaring Camp, p. 1.) "Can you give us a square meal?" "This is all a fair, square, bona fide (fide to be pronounced as a monosyllable) business enterprise, is it? (Putnam's Magazine, August, 1868.)
Among the earliest definitions of the phrase is this one from a glossary of "Californianisms" included in John Hittell, The Resources of California, Comprising Agriculture, Mining, Geography, Climate, Commerce, Etc. Etc. (1863):
Square Meal, a good meal at a table, as distinguished from such meals as men make when they are short of provisions, a condition not uncommon among men who make adventurous trips into the mountains.
So it's not surprising that perhaps the earliest Google Books match for "square meal" occurs in "The World in California," in Hutchings' California Magazine (February 1857):
He ["the Miner"] almost invariably attends church on Sunday, or visits some city, town, or village where there ought to be one,—and though he seldom works on that day, his presence in town makes everybody else work. His weekly supply of "grub," and his one "square meal" on Sunday, he will have ; picks must be sharpened, and his boots made thicker on their bottoms; ...
Several other authors writing in the 1860s (including Mark Twain in The Innocents Abroad [1869]) report that "square meal" is native to California, so perhaps it really was.
An Ngram chart of the frequency of "square meal" from 1850 to 2005 shows a gradual decline since roughly 1920:

but I agree with the commenters above who say that the expression remains fairly common in informal U.S. English.
Update (August 10, 2022: instances of 'square meal' from 1856
An Elephind search of multiple newspaper databases turns up six instances of the term "square meal" from 1856—the year before the earliest Google Books match—all from California newspapers.
From a letter from "Pike" of El Dorado County, California, in the Georgetown [California] News (February 7, 1856):
If you or any of your readers should visit our town, call at the United States Hotel, for every person goes there to get a square meal. Bill is conversant with the diggings and can give all the information requisite to purchase or locate in the place.
From "Dry Times," in the [Bidwell, California] Weekly Butte Record (March 15, 1856):
These two great sources of wealth [mining and farming] being dried up, of course the people of the State at large are all suffering in consequence. The merchant gets nothing but doubtful scrip for his warres, and he in turn employs the mechanic on a prolonged "Cred." Litigations naturally naturally ensue, and counsellors of acknowledged wisdom and skill are obliged, in their turn, to accept of "slow notes" in remuneration for their services ; they and gentlemen of other professions and occupations put severely to the test the patience, forbearance and solvency of their unfortunate landlords. Rendered doubly suspicious by the pressure of the times, the dependents on their wits are often obliged to resort to stratagem and stealth for a "square meal," and as frequently are baulked, and obliged to go hungry. Let us all merchants, professional men, mechanics, miners, farmers, landlords and all—pray for rain.
From "Gov. Johnson and the Press," in the [Coloma, California] Empire County Gazette (June 7, 1856):
Tho Governor [Johnson] was telegraphed to, and went to San Francisco in good faith, to suppress, if possible, the organization of the body styled the Vigilance Committee. When he arrived at the Bay, the excitement was running so high, and so much in one channel, that the Governor was counseled by the very gentlemen who had urged his visit—Gen. Sherman, among the rest—not to undertake, at that time, to resis[t] the insurgents. He saw that even if he could prevail upon a few men to take up arms against the masses, it must he a hopeless sacrifice of life, and that in view of the cause of the movement he would better subserve all interests by letting Casey and Cora expiate their crimes, even though at the hands of a law-defying commmunity--hoping that when the demand for blood was appeased the insurgents would voluntarily lay down their arms. They did not, but persist in prosecuting inquiries having reference to the moral character of citizens, and the Gov., seeing that they have not the plea of excitement in their favor, and that they seem disposed to continue the organization after the creating outrage has been avenged—seeing this state of affairs, the Governor calls upon them to disband, and takes measures to insure obedience. We think lie is right—and have additional reason for so thinking, in the fact that the Ned Buntline writers at the Bay are censuring him for his course. They too speak from pure motives--of interest! "The Craft's in danger!" They get square meals, and extend the circulation of their papers, during these excitements!
From "Black Republican Barbecue," in the Chico [California] Record (October 27, 1856):
From the appearance of certain of the candidates and hangers on ... we are led to believe that a good square meal off a portion of that black sheep would help resusitate [sic] them. But then, it would be so much like Cannibalism!
From "Meeting of the Boarders at de Legates," in the Chico [California] Record (December 2, 1856):
The eloquent and feeling remarks that accompanied this magnif. and appropriate token of your and my ability to buy such things, ’lights on my overpowered feelings like a lunch eater on a square meal. If during the two weeks that 1 have served as the secretary of our order, I have done anything to show that I aint mean, why let her rip.
From an untitled item in the Chico [California] Record (December 15, 1856):
The people of San Francisco have tendered a public dinner to Consul Dillon, and that functionary has accepted the invitation to the proffered "square meal." The distinguished gentlemen of the Bay City are somewhat celebrated for their appetites, judging from the many big dinners they eat.
An instance from January 1857 appears in "Personal," in the Chico [California] Record (January 23, 1857):
An individual by the name of Bruin, arrived in town yesterday from the vicinity of Shasta, His friends, actuated by motives of extreme personal regard, and with praiseworthy care for his safety and convenience, (unappreciated by him, however,) brought him all the way from his former residence to Oroville, in a conveyance made expressly for his accommodation, and during the entire journey have generously provided him with comfortable lodging and square meals, notwithstanding bis ungrateful growlings at their very acts of kindness.
Another instance appears in "Gambling and Gamblers," the Stockton [California] Independent (February 28, 1857), reprinted from the [Sacaramento, California] Temperance Mirror:
Since the good old times of '49, when men could make an ounce a day and upwards with a butcher knife and a wooden bowl, to the present day, when men are lucky if they make three dollars, with the best means of working known in the mines, one class of men have lived in California who have never done work enough to pay for a "square meal." We speak of that peculiar class known as gamblers by the public, but who themselves rejoice in the appellation of "sports." These gentry at one time were a power in California, and threatened to become a permanent institution, hut the decrease in wages, and the increased difficulties in acquiring gold, had a very disastrous effect on their business, as well as on those who were engaged in more honorable pursuits.
Likewise, a letter from Amador County, California, dated March 7, 1857, to the editor of the Sacramento [California] Daily Union (March 12, 1857), likewise uses the term "square meal" in reference to a (presumably) meal at a French restaurant.
El Dorado (where the town of Coloma was located), Amador, and Sacramento counties are adjacent to one another in north central California. Chico is the largest city in Butte County and lies about 86 miles north of Sacramento. Stockton, California, the county seat of San Joaquin County, is about 48 miles south of Sacramento. These early newspaper instances of "square meal" fall within a fairly small area of California, providing strong circumstantial evidence that the term may have originated there, perhaps (since all of these locations fall within the region known as California gold country) among miners and prospectors.