Cell membranes are vital to cell health because they keep the important cell companents contained, and protect the cell from external stress and intrusion of toxic or biological threats. Membranes form through the movement of lipids in reaction to water: these lipids are hydrophobic on one end and hydrophilic on the other -- one side attracts water and the other side avoids water.
As the cell forms, the hydrophobic sides of the lipids move together to stay away from the watery environment of the body. These lipids link their hydrophobic sides and present their hydrophilic sides to the outside and inside of the cell, creating a membrane. The membrane is also reinforced and supported biologically by various proteins, called extrinsic (outside) and intrinsic (inside), which help to transport materials through the membrane. Cell membranes can be composed of more or fewer proteins or lipids, depending on the size and location of the cell.
As the membrane is technically made of millions of individual lipids, the membrane is flexible and can change its shape and diffusion or osmosis level. This allows the cell to regulate the various compounds and molecules that keep it healthy, and keep its interior at the correct level of moisture and salinity.