Roughly 200 miles from San Francisco, 300 miles from Los Angeles, and 500 miles from Las Vegas, Yosemite takes a while to reach—and its many sites and attractions merit much more time than what rangers say is the average visit: four hours. Most people arrive via automobile or tour bus, but public transportation (courtesy of Amtrak and the regional YARTS bus system) also can get you to the valley efficiently.
Of the park's four entrances, Arch Rock is the closest to Yosemite Valley. The road that goes through it, Route 140 from Merced and Mariposa, is a scenic western approach that snakes alongside the boulder-packed Merced River. Route 41, through Wawona, is the way to come from Los Angeles (or Fresno, if you've flown in and rented a car). Route 120, through Crane Flat, is the most direct route from San Francisco. The only way in from the east is Tioga Road, which may be the best route in terms of scenery—though due to snow accumulation it's open for a frustratingly short amount of time each year (typically early June through mid-October).
There are few gas stations within Yosemite (Crane Flat, Tuolumne Meadows, and Wawona; none in the valley), so fuel up before you reach the park. From late fall until early spring, the weather is especially unpredictable, and driving can be treacherous. You should carry chains.