As with most things about travel in the U.S., the answer varies from state to state and from city to city. Yes, broadly speaking, it's possible to travel in the United States without paying for lodging, but I would not say it is especially easy or comfortable. There are many campsites where the fee is quite nominal (under $20), budget motels in rural areas, and hostels in larger cities.
For a foreign visitor, my recommendation would be to overnight only in areas where it is explicitly permitted. Outside of them, whether sleeping in your car or out in the open, things are riskier as I detail further below.
FreeCampsites.Net provides a community-maintained listing of locations where you can camp overnight for free or at very low cost, organized by state. Most of the profiles include some information about facilities and ease of access. Note that many of the submissions are from the perspective of recreational vehicle (RV) drivers, so read each one carefully— if you just need a place to park for the night, you won't care about a lack of RV hookups, but if you want to sleep outdoors, the parking lot of a Wal-Mart would not be safe.
If you'll have a car, some states permit overnight parking at designated rest stops or service plazas, located along interstates and other major highways, and a handful allow camping at them as well. The Internet resources I checked are highly inconsistent, however, so check each state's rules.
I have on occasion driven into a national or state park and slept in the car in the parking lot at the visitor center, where it is not explicitly prohibited, because all the campsites were full or because the gate was closed. But there is a general sort of safety risk you incur, as they are unsupervised at night and there are few people around.
Truck stops are another possibility for motorists. These are facilities which provide services and overnight parking for long-distance haulers, so they will be staffed overnight and have food and fuel— and will be noisy and busy and full of truckers. You should not park in spaces designated for semi-trailer/tractor trailer trucks, for safety and courtesy— they fill up quickly in some areas. But such facilities will usually have a few spaces for cars, and tolerate overnight parkers. TruckStopGuide.com is one directory.
Yet another resource is SleepingInAirports.Net, community-maintained, and covering not only airports but some bus and train stations as well. If you have a car, you will still need to find overnight parking, but sleeping inside the facility may be safer. Not all such facilities are open 24 hours, however, and not all tolerate sleepers. At Union Station in Washington, D.C., napping in the gate area before my 3:30am train, dressed professionally and clutching a rollaboard bag, I was repeatedly woken by security personnel (not police) demanding to see my ticket.
See Is it safe and legal to sleep in my car in California (L.A. area)? and Can I get arrested for loitering? for closely related questions.
It's a big, wide, open country, and you can probably "get away" with sleeping in your car in the parking lot of any large 24-hour store (e.g. some supermarkets and Wal-Marts), for instance, in suburban and rural areas, or while parked on the street in cities. There are many homeless people who do so, after all. Sleeping rough is a different story, and there are some cultural and legal points to be aware of.
First, a large number of municipalities and states have anti-loitering or anti-camping codes, and while the courts have struck down many anti-vagrancy laws, others remain on the books. What this means is that it is often illegal to camp overnight even on public land, such as a municipal park or parking garage, except at a designated campsite.
Loitering, staying in a public place for longer than a designated amount of time without a specific purpose (usually a few hours), is barred in many places, but very unevenly enforced. Generally, they are justified on grounds of reducing criminality or protecting public health, though they are often an excuse to exclude some "undesirable element," such as teenagers or the homeless, from an area. With regards the latter, many municipalities have enacted explicit anti-camping laws, particularly in the West. The wording of the code in Alameda or Susanville is very typical:
It shall be unlawful for any person to camp, occupy camp facilities or use camp paraphernalia in the following areas, except as otherwise provided:
- Any park;
- Any street;
- Any public parking lot or public area, improved or unimproved
- Any publicly owned property that is designated for public or government use
Thus, if you go to a city park at night and try to sleep on a bench, depending on the city and the park, there is a possibility the local police will wake you, ask you what you are doing, and have you move "elsewhere"— or, if you are in a more tolerant city, you will be competing for those spots with the homeless who have been forced out of the neighboring town.
Second, understand that even in remote areas, most land in the U.S. is either a public reserve or privately owned; moreover, there is no freedom to roam and no culture of rambling (hobo/tramp tropes notwithstanding). As such, you may be confronted by law enforcement for trespassing, and while it is illegal to shoot someone for merely trespassing (contrary to stereotype), that does not mean a landowner will not show up with a firearm to make a strong implication otherwise (consonant with stereotype).
Sleeping in your car, or outside, does entail the risk of crime. There may be criminals who target tourists at unmanned rest stops, and there are others who, encountering someone vulnerable, will commit a crime of opportunity. You would be well-advised to park overnight in well-lit areas where there are others around, but note that truckers are attacked even at designated rest stops.
For a different sort of security, I would also caution strongly against merely pulling off to the side of the road. First, stopping on the shoulder except for emergencies is illegal on many roads. Second, accidents involving vehicles on the shoulder are disproportionately likely to occur at night, attributed in part to the "moth effect" (a kind of "target fixation") where drivers are drawn inexorably to drive toward lights— quite deadly at highway speeds.