These are simply advertisements related, in theory and often practice, to the content of a page.
While contextual ads. can be engineered by you, the most common type is Google adsense. Google adsense is probably the easiest to install, and demands very little of your time.
A publishing account is opened, and after approval, you will have access to the code that makes it all happen.
After that, you just need to copy it and paste it into the page, at the editing stage.
The position that your contextual ads. appear in, when viewed through a browser is up to you, though some S.E.O.'s have theories on the optimum position. Their concerns centres around placing such code out of the way, more so than placing it in an area of maximum visual prominence, but that is a debate for another day.
If a page is optimised, in S.E.O. speak, your contextual ads, will generally reflect the content. In other words, an optimised page having optimised keywords relating to EGGS, will produce ads about or relating to EGGS.
It is a targeting strategy. A visitor wishing for information on that four-lettered E word would most likely have a thirst for further information. Should that be the case, a potential sale could be made.
This theory of targeting is the fundamental basis of all functional advertisements.
In the absence of an optimised page, Google Adsense must make it's own assessment of what is going on, and a contextual ad is returned on that.
Science, being what it is, must be throughout for maximum benefit and it is hardly the fault of Google if true reflection or context, doesn't happen.
Public Service Ads. can also be ran in, where nothing more suitable is found from the advertisers, and any commercial benefit is theirs. These ads. are mainly donation related, but not exclusively and are also automatically generated.
Having said that, in a lot of cases the publisher doesn't really care and is happy with some automatic ads., rather than none. Incidentally, these ads. can be coloured and formatted to suit the general theme of your site.
In other cases, contextual ads. can make a pleasant and subtle distraction to a page that is mainly dedicated to text.
Any income that may be generated by contextual ads. is really down to your S.E.O. ability, the ability of your S.E.O., curiosity of the visitor, the number of them, and any proportional advantages that the number of pages may bring.
Seamus Dolly and an example of "ad. alignment" are at http://www.CountControl.com/contextualads.html