From The Aquarium Wiki
What is it?
A bubble nest is made out of the mucus of fish and is a white foamy bunch of bubbles on the surface of the water. It can range in size and width from being compact and deep to shallow and spread out. It is most often "anchored" to objects on the surface including leaves of plants and tall submerged objects that break the surface.
What created it?
It is primarily created by the male fish, typically of some of the freshwater fish of the anabantoid group. Occasionally females may contribute or build these nests also but it is a lesser known occurrence.
What is it for?
The male fish creates the nest to collect and guard the fertilised eggs from a female.
Male fish, especially fancy Betta splendens, are known to create these nests when in new environments or after water changes provided there is little or no surface movement, possibly simply to establish their territory.