I know, I know, the government can focus on more than one thing at once, but I'm sure the reasons impelling him and Congress to do this right then, during the height of the Civil War, had to be more than mere whimsy.
The short answer is that neither Congress nor President Lincoln spent much time on it at all. A man named Israel Ward Raymond had visited the Yosemite Valley and wrote a letter to Senator John Conness of California urging the protection of the valley in February 1864. Senator Conness forwarded the letter to the General Land Office, along with his request to prepare such a bill to protect the area. Speaking before the Senate, Conness requested the protection of the area that was "...for all public purposes worthless, but which constitute, perhaps, some of the greatest wonders of the world." He continued to explain that the area was intended to be "...preserved and improved as a place of public resort."
The Yosemite Grant Act, passed into law on June 30, 1864, states that the land "...shall be held for public use, resort, and recreation; shall be inalienable for all time, but leases, not exceeding ten years may be granted for portions of said premises; all incomes derived from leases of privileges to be expended in the preservation and improvement of the property, or the roads leading thereto..." Upon its creation, the Yosemite Grant had dual purposes -- preservation for public use and recreation, as well as short-term leases for commercial purposes. The income generated by leasing the property was intended for the improvement and preservation of the Yosemite Grant. No funding was offered by Congress, and the commissioners this law stipulated should manage the park were specifically to receive no compensation for their services.
In short, the government spent little to no money on this, and very little time as well. Why did it happen when it did? It seems to be primarily because of squatters beginning to take up residence in the valley at this time. James Mason Hutchings first visited the Yosemite Valley in 1855. Hutchings was a journalist and publisher, and believed the valley made for an excellent topic for his magazine, Hutchings California Magazine. His many feature articles concerning the valley greatly increased the public's knowledge of the area. In 1862, Hutchings moved into the Yosemite Valley, taking possession of the Upper Hotel. He claimed, by right of occupation, more than one hundred acres of land in the Yosemite Valley. With the passage of the Yosemite Grant Act in 1864, settlers were no longer allowed to own property within the Yosemite Grant. The commissioners offered Hutchings, along with another settler, James C. Lamon, the stipulated leases not to exceed ten years. Both men refused, and brought their case before the California legislature. The California legislature agreed with the men, and offered them title to 160 acres of land in the valley, passing the law over the veto of the governor. It required, however, acceptance by the US Congress. The bill easily passed in the House of Representatives, with California Representative James A. Johnston saying, "The Constitution and the laws are for the protection of citizens, and not for the creation of fancy pleasure grounds by Congress out of citizen's farms." The Senate, however, refused to pass the bill because the land had not been surveyed as required for right of occupation to allow settlers to claim land.
The commission then brought suit against Hutchings to expel him from the valley and seize his lands. The case was eventually brought before the Supreme Court, where in Hutchings v. Low, Hutchings lost his case in December 1872. In the decision, the Supreme Court wrote, "It seems to us a little less than absurd to say that a settler... acquires a right to compel the owner to sell..." All of the private property in the valley was seized, however the settlers were not left with nothing. Four men lost their claims and received payment, with Hutchings receiving $24,000. This was a considerable amount, and the commissioners wrote that "the State had dealt by them most munificently."
I hope that answers your question. Sorry if the answer occasionally strayed from your question, I copied most of it from an applicable portion of a research paper I wrote last fall.
Bibliography
Hutchings v. Low, 82 US 77 (1872).
Raymond to Conness, February 20, 1864, Yosemite -- Legislation, File 979.447, Y-7, Yosemite Research Library, Yosemite National Park, CA.
Runte, Alfred. Yosemite: The Embattled Wilderness. Lincoln: University of Nebraska Press, 1990.
State of California. Biennial Report of the Commissioners to Manage the Yosemite Valley and the Mariposa Big Tree Grove. Sacramento: FP Thompson, State Printer, 1877.
State of California. Message of Gov. H. H. Haight, Transmitting the Report of the Yosemite Commissioners (1868/69) and Memorial of JC Lamon. Sacramento: DW Gelwicks, State Printer, 1870.
US Congress. Congressional Globe. 38th Cong., 1st sess., May 17, 1864.