This is a bit of chemistry. Soap molecules have two ends — one end likes to stick to water, and the other end is repelled by water. read more
When you mix these two things together you create a process called saponification, basically making soap. Certain oils help create bubbles. For example Coconut, and castor create nice big creamy bubbles. Olive oil makes smaller bubbles. Commercial soap makers add synthetic foamers. Sugar can also be added, and that too helps with the bubbles. read more