Sleeping in a car parked on the side of the road is in most locales illegal, but in certain circumstances can be one of the best options. These can include stranding by mechanical problems or intoxication, lack of funds, or a problem which otherwise prevents the driver from continuing, such as loss of contact lenses.
When I was 19 and flew from California to San Antonio to purchase a Crown Victoria Police Interceptor, I found myself that night without funds until at least midnight due to daily bank caps on usage of debit cards to get a room for the night, and no other obvious options for a location to sleep. I sought out the best option I could come up with: I slept in the car over where I saw some trucks parked for the night by a filling station on the south end of Fort Worth.
With my contact lenses out, which had been threatening to fall out for hours prior, I crawled in back to get some shuteye. I found myself awakened in the backseat of an ex-cop car with a present cop knocking on the window and shining his flashlight in my near-sighted eyes a few hours later. I put up a hand to shield my eyes, and was asked to open the door. Confused, nearly blind, and still tired, I opened the door as requested.
After the obvious questions such as "Why were you sleeping in the car?" (Because I was tired, and it seemed safer than driving tired with contacts potentially falling out) and "Why didn't you get a room in that motel not a hundred yards away?" (Because I was completely devoid of funds other than the $20 bill in my pocket until midnight PST), he finally told me I couldn't sleep there. I asked where I might sleep, and he just told me "Not here."
I thanked him, for lack of a better idea, and got back in, put in my somewhat moisturized contact lenses. I went down the freeway a few miles and pulled in at a Denny's and proceeded to be confused when I was asked whether I wanted smoking or non. Being a Californian at the time, I was so accustomed to it being illegal to smoke in business establishments that it took a minute for my tired mind to wrap itself around the question and comprehend what I was asked and stop responding with "one".
I sat around there for about three hours until sunup, drank a lot of coffee, and grabbed a bite to eat, concluding that if I ever ended up in the predicament of having nowhere to sleep, I could find something better than the back of my car. Especially now that I have left the spacious Crown Victoria behind, since that would mean someplace very uncomfortable. Namely, the back seat of a Volkswagen.