Why does soap form a "film," ie a surface?
Soap solutions are typically water-based and contain some form of soap, which is an amphiphilic. This means that the soap molecules contain a hydrophilic head and a hydrophobic tail. At the molecular level, these particles become arranged at the water/air surface so that the tails are sticking out of the water while the heads are in the water.
Therefore, the soap solution forms a thin film of water, surrounded on both sides by air, with the soap molecules working as a barrier to hold the film in place.
Why do bubbles form the shapes they form?
The soap film is an elastic surface. This is because the soap molecules create a repulsion between both surfaces of the film, preventing it from thinning and consequentially bursting. Indeed, soap film will naturally flow to minimize surface tension. Because the surface tension is proportional to the surface area of the film, this is achieved by trying to minimize surface area - which, in turn, is done by trying to make the surface's curvature as small (and uniform) as possible across the entire surface.
For example: Why are bubbles round spheres? It's because bubbles spheres are the shapes that minimize their surface area out of all surfaces that enclose a fixed amount of volume!
When a soap film is spread across a wire frame, the result is a surface that tries to minimize surface area out of all other surfaces with the same frame. The results are often a stable, beautiful surface!
A little more math
More concretely: when a thin surface separates two media (M1 and M2) in the physical world, the surface will satisfy the Young-Laplace Equation
pressure(M1) − pressure(M2) = 2H
where H is a measure of the curvature of the surface. In the case of a soap film, we have that M1 and M2 are the same (namely, the atmosphere), and their difference is 0. Therefore, soap films will satisfy the equation
H = 0
which is the equation that describes such surfaces with minimal surface area!