Where I am located it is legal, and honestly there is not much alternative.
The roads google maps instructs me to take for their bicycle directions are not bicycle friendly. I am directed to take a narrow road with just one lane on each side with motorists going 55 mph, even though there is heavy traffic and no room for motorists to safely pass.
It seems like google maps is optimizing for road incline instead of safety. I resorted to using their pedestrian routing to get a route with sidewalks, but of course then it doesn't take road incline into account. No E-bike here. And then oddly enough, the other day their pedestrian routing sent me through A CONSTRUCTION ZONE. That path was definitely not bike friendly or pedestrian friendly.
Google maps' bicycle directions never send me down a greenway, it always wants me to be right beside cars. If I have already biked 10 miles, you really don't want me to be right beside cars, as my bicycling becomes more unsteady as I become more tired.
Riding a bike on the sidewalk (or a divided bike path) is actually pretty dangerous. Cars aren't expecting there to be 15-25 mph traffic when they pull in to driveways or make turns.
The most common type of bike accidents are cars failing to yield when turning or using driveways, and divided bike paths and sidewalks only make it worse.
I try to be super vigilant when crossing crosswalks and driveways when using the sidewalk, but pretty much all of the close calls I've had have been because I was riding moderately fast on the sidewalk.
It might solve the complaints motorists have, but then you'd have the complaints of pedestrians to deal with. In two major cities in my country, bike lanes have been added to the pavements as a bright red stripe on the side of the pavement closest to the road. Local pedestrians shouldn't walk on that portion of the pavement, but they still do, and if you ring your bell or shout for them to give way, they either ignore you or yell at you. It’s actually much faster to simply cycle on the road with the cars.
Good god, please no! The most harrowing pedestrian segment of my commute isn't crossing the 8-lane highway with poorly timed lights (though that's a close second). It's the one block where the bike lane is officially marked as being on the sidewalk.
The legality of riding your bike on the sidewalk varies by state, county and town.
In a couple of places in Portland there are signs specifically directing cyclists to use the sidewalk because of streetcar tracks.