Function
The cell membranes main purpose is to allow certain materials to pass through it, and some others to not. It was first discovered by Anton van Leeuwenhoek in 1665 when he first saw the cell and changed the way scientists looked at the cell. The cell membrane actually acts a lot like a fence with gates; it only allows certain people who you want in there in and others out. The cell membrane was discovered in The phospholipid bilayer keeps everything where it should be inside the cell or outside, but allows for some materials to diffuse across the membrane. The active transports, or proteins that are located around the membrane are what move materials through the membrane. ATP is used as energy to activate the proteins and allows for materials to be transferred. The names of these proteins are transport proteins, receptor proteins, glycoproteins, and structural proteins. The purpose of a glycoprotein is to communicate from one cell to another and transfer of molecules. Structural proteins attach to the cytoskeleton and help move the membrane to make different shapes. Receptor proteins communicate with the external world by hormones and neurotransmitters and relay information back to the nucleus. Transport proteins are what a cell uses to move materials to and from the cell. I have also given the link that will take you to a short video on how the cell membrane and some of its protein work together with other cells.
Structure
The structure of the cell membrane is fairly simple, it is composed of a phospholipid bilayer dotted with proteins. The phospholipid bilayer allows for the cell membrane to be flexible and move around and can make up from 20 to 80 percent of the membrane. The rest of the membrane is made of proteins that allow for particles to transfer across this barrier. Glycoproteins, structural proteins, receptor proteins, and transport proteins are all embedded in the cell membrane and are involved with some sort of action. I have a link below to a scientific paper relating to how Na+ and K+ are transferred across the cell membrane in different types of cells like neurons.