The sidewalk is one of the most dangerous place you could ride your bike.
Thank you WS, I was surprised this wasn't mentioned earlier.
There's a difference between perceived safety (comfort) and actual safety. I definitely remember the initial feeling of riding in the road, seeing the sidewalk and thinking why am I in the road. Luckily for me I had a great bicycling mentor (LAB instructor and all that). The discussion that got me to change my mind:
Master Cyclist: Why do you think bikers get hit?
Me: 'Cause drivers don't pay attention and look for me.
MC: Where is the one place that all drivers are looking, even the ones checking their phones?
Me: ...right in front of them?
MC: Exactly. Almost all close calls end with a "Sorry, I didn't see you."
Me: But won't they get angry and give me a "punishment pass"?
MC: It's this strange psychological phenomenon, almost everyone moves completely into the other lane since they know they have to pass over the paint no matter what. And if they don't move over completely, they move more than they usually do when I'm edge riding.
Me: But what if they don't know how to slow down and rear-end me?
MC: They slow down for cars turning right, for post office vehicles, for pedestrians crossing the road, for buses, ...
Me: Ok, let's try it.
Life changing experience ensues. Try it for 2 weeks, the difference is like night and day. Funnily enough, the "primary position" is supported by every biking resource that I've found. Some places to start:
https://www.bikeleague.org/content/commutingAlways ride with the flow of traffic
Do not ride on the sidewalk
Allow yourself room to maneuver around hazards
If the lane is too narrow or you are going the same speed as traffic, take the lane
http://www.azbikeped.org/bicycling-street-smarts-02.asp"It may seem dangerous to make a motorist slow for you, but it's not. The usual reason that bicyclists feel unsafe on narrow roads is that they do not take control of the situation. Remember, the drivers behind you don't have room to pass you safely anyway. If you ride all the way over at the right, you're inviting them to pass you where the road is too narrow and, too often, you will get squeezed off the road. If you show clearly that it's not safe for drivers to pass you, they're unlikely to try.
Remember: don't hesitate to leave the bike lane when necessary for your safety - all the guidelines about lane position in this book apply whether or not there is a bike lane.
Many cyclists believe they are safer and more comfortable riding further to the right than this booklet recommends. They fear being passed uncomfortably close by a motorist, or feel intimidated by impatient drivers. Riding too far to the right is very dangerous for several reasons."
https://gohs.az.gov/highway-safety-programs/bicycle-safetyYou may ride far enough from the road edge to stay clear of surface debris, potholes, rough pavement, drain grates, and pavement joints, as well as to avoid pedestrians, dogs, parked vehicles, and other objects.
You may occupy any part of a lane when your safety warrants it. Never compromise your safety for the convenience of a motorist behind you.
https://www.azleg.gov/viewdocument/?docName=https://www.azleg.gov/ars/28/00815.htm Arizona, USA specific but most states'/western country's laws are very similar and easy to look up.
ARS 28-815
A person riding a bicycle on a roadway at less than the normal speed of traffic at the time and place and under the conditions then existing shall ride as close as practicable to the right-hand curb or edge of the roadway, except under any of the following situations:
If reasonably necessary to avoid conditions, including fixed or moving objects, parked or moving vehicles, bicycles, pedestrians, animals or surface hazards.
If the lane in which the person is operating the bicycle is too narrow for a bicycle and a vehicle to travel safely side by side within the lane.
...
tl;dr Here's some quick resources:
https://cyclingsavvy.org/road-cycling/https://floridabicycle.org/for-motorists/https://www.bikeleague.org/ridesmartAnyways, that was much longer that I intended. So much great info that we're never taught or shown.
Happy riding!