Can anyone tell me why the flight route for most of these flights from LAS to SFO is flying northwest along the Nevada border, then almost directly west to SFO?
Air traffic control. There is a lot of flights between the Bay Area and Southern California. Flying the way you described gets that traffic out of the way.
The flights from the Bay Area to LAX often fly along the coast. The flights to the Bay Area fly up the Central Valley.
The route skirts the edge of the bombing range.
The southbound route is usually a little further east than the northbound route once it crosses the Nevada stateline.
You have 2 MOAs to deal with: R-2502 to the west (Edwards/Desert MOA), then the Nellis Range (R-4806W and R-4806E) to the left. R-2502 is active from SFC-Unlimited Mon-Fri, with Nellis hot SFC-Unlimited everyday.
There would be only 2 ways to get to SFO: on J110 through R-2502, over to Fresno and then up, or through the J92 corridor to Coaldale, then west. J92 is the only High en route airway that splits the MOAs, plus gets you north of the R-2502.
On top of that, at OAL, you have J58 coming in that most of the westbound arrivals to the Bay area come in on, so they join that stream there.
For those not in the know, the route from KLAS-KSFO is SHEAD5.OAL.MOD3 (if RNAV capable), or MCCRN3.BTY J92 OAL.MOD3 (non-RNAV). If SFO is in East Ops, replace the MOD3 arrival with the LOCKE1 arrival.
On the way back, the route is PORTE3.CZQ BIH LIDAT BTY.SUNST2 (if RNAV-capable), or PORTE3.CZQ BIH LIDAT BTY.FUZZY7 (non-RNAV). Charts for those are available here.