Does the main washing effect of soap come from foam?
Foam is a side effect of using a tensio-active agents (though some tensio-active agents are engineered to produce as little foam as possible, e.g. in washing machines). In fact, you could consider that, if soap has nothing better to do, it will form foam. This answers some of your questions: foam does not (really) carry away dirt and its percentage of efficiency in the whole process is low.

Molecules of soap are made of 2 parts: a hydrophobic tail (which loves fat, grease, lipids, whatever you call them) and a hydrophilic head which loves water, and hate lipids.

When the hydrophobic tails are busy linking to a greasy stain or grease on your hands, they no longer participate into forming bubbles/foam.

The easiest way to verify that is to pour a little bit of oil in your hands and rub them. Wash your hands with soap a first time: there will be almost no foam. Now rinse your hands and wash them again: there should be much more foam!

Note that it does not mean that your hands are cleaner, regarding bacteria, but just that they are less greasy!

If you want to remove bacteria, rub your hands with soap for at least 30 seconds. So-called "anti-bacterial" soaps do not achieve better and promote bacterial resistance.