pH is the standard measure of the acidity or alkalinity of a solution1. It relates to the concentration of free protons in a solution – a large number of protons corresponds to a low pH, which is to say an acidic solution. If a particularly small number of protons is available, the pH is high and the solution is alkaline.
If that sounds a bit abstract, bear in mind that it's just a physical description of a very familiar chemical property – acidity is what makes things taste sour; some languages, like German, have the same word for 'sour' and 'acidic'. It's also one of the first things anyone ever learns about chemistry, so it's interesting that it's so difficult to pin down a clear physical description of the nature of pH – what do any of the well-known properties of acids have to do with protons?
How Acids Work
Besides tasting sour, acids also have the power to 'burn' or dissolve some materials. They do this with a kind of two-pronged attack. Every molecule of a standard acid is made of at least one hydrogen atom attached to one or more other atoms; the hydrogen breaks off from the rest of the molecule when it dissolves in water, leaving its sole electron behind2. Without its electron, a hydrogen atom is just a proton3. A proton has a positive charge, while the other part of the acid4 will have a negative charge – hydrochloric acid, for example, divides into positive hydrogen ions and negative chlorine ions.
Usually, anything with an excess charge like this will take any opportunity to lose it, and if a couple of those protons manage to grab a pair of electrons from somewhere they'll immediately make off with them to form a nice stable hydrogen molecule. Similarly, the negative ions will off-load their extra electrons at the first chance they get. One way to do this is by finding a positive ion to form a compound with; metals are handy for this, because they are essentially made of positive ions held together by free electrons. So the negative part of the acid (the anion) takes a positively charged atom out of the metal at the same time as the positive part (the proton, a cation) grabs an electron to maintain the overall charge. The metal dissolves into the liquid, and hydrogen bubbles escape.
How Bases Work
The flip-side of this is basicity (or alkalinity - an alkali is a base that dissolves in water). Bases remove protons, usually by giving them a hydroxide ion to react with5. Oxygen is very attractive to electrons6, so when hydroxide breaks away from a larger molecule, it takes an extra electron with it and leaves the remainder of the base with a positive charge. Often what's left behind is something that wasn't particularly keen on keeping that electron in the first place – the alkali metals can hardly shed them fast enough7, which is why they react so dramatically with water.
Since acids are proton donors, while bases are proton acceptors, they neutralise each other, producing water (OH- add H+ gives H2O) and a salt. Table salt (sodium chloride) is the salt you get from reacting hydrochloric acid with sodium hydroxide, but chemists define a salt as any compound that can be produced in this way.
Alkalis can also burn or dissolve various things, but the really interesting thing they do is to turn fats and oils into soaps. This process, known to humans for thousands of years, is called saponification, and it's the reason alkali solutions feel slippery on our fingers – our natural skin oils are changed instantly into detergents. The hydroxide breaks up the fat molecule into glycerol and fatty acids, while the other bit, for example the sodium or potassium, reacts with the fatty acid to produce soap.
How pH Works
The pH is the negative logarithm of the concentration of hydrogen ions in a solution, which sounds much harder to understand than it actually is. What it means is that every time the concentration of hydrogen ions goes up by a factor of ten, the pH goes down by one. A concentration of 0.1mol/l has a pH of 1; a concentration of 0.01 has a pH of 2; 0.001 is pH 3, and so on. Concentrations in between have pH values in between. It happens that the concentration of hydrogen ions in pure water at room temperature, or a strictly neutral solution, has a hydrogen ion concentration of 0.000,0001mol/l, and hence a pH of 7. Anything with more hydrogen ions is acidic, and has a lower pH than 7; anything with fewer hydrogen ions (and more hydroxide ions) is alkaline, and has a pH higher than 7.
1Note that acidity of a substance can also be measured by its dissociation constant, Ka. This describes a chemical, rather than its solution, so unlike pH it doesn't change with the strength of the solution, and also work with things that aren't solutions
2Technically, I'm only talking about acids by the Arrhenius or Brønsted-Lowry definitions here; according to the Lewis definition an acid is a substance that can accept a pair of electrons to form a covalent bond
3Actually, a lone proton is so reactive that it will invariably attach itself to one or more nearby water molecules, making H3O (hydronium) or more likely something like H5O2 or H9O4
4Which, confusingly enough, now counts as an alkaline – the conjugate base of the acid
5The early Arrhenius theory of acidity only recognised compounds with hydroxide as alkalis, but this has now been superseded by the Brønsted-Lowry theory, in which any proton acceptor is a base, and any soluble base is an alkali
6That is, it is highly electronegative
7That is, they have very low electronegativity