The resting membrane potential of a cell is maintained by the sodium-potassium pump and is possible because the membrane itself is not very permeable to ions. The sodium-potassium pump uses the energy stored in ATP to pump sodium and potassium across the membrane.
The resting membrane is established and maintained because the phospholipid bilayer contains a middle section that repels charged molecules and ions. As a result, the ions can only pass through the membrane if there are channels for the ions. Certain molecules, such as DNA and many negatively charged protons, contribute a negative charge to the cell and cannot diffuse out along their concentration gradient.
These negatively charged molecules in the cell allow the cell to maintain a concentration gradient by pumping the positively charged cations alone. Although both sodium and potassium ions are positively charged, the negative-inside membrane potential is maintained because the sodium-potassium pump doesn't pump the same number of each ion. Instead, for every cycle of the sodium-potassium pump, one ATP molecule is used to pump two potassium ions in and three sodium ions out. More positive ions leaving the cell means that the membrane interior is getting more and more negative overall.
Using these pumps and controlling other cation channels in the membrane, the cell is able to maintain a negative resting potential.