The green coffee beans have no flavour or aroma and are just a pale green shadow of their future dark brown selves. All of the flavour and aroma that we enjoy in coffee is created by roasting the beans.
Green coffee beans are heated to between 180 and 240 degrees centigrade for 8 to 15 minutes, depending on the degree of roast required. The longer the coffee is roasted the darker it becomes. During the roasting process moisture is lost and the bean "pops" audibly rather like popcorn. A chemical reaction takes place: starches are converted into sugar, proteins are broken down and the whole cellular structure of the bean is altered. The heating process precipitates the release of coffee oil, or what is called "caffeol", which is the essence of coffee.
This essence of coffee is what we enjoy in the cup. It is also volatile and water soluble, so once the coffee beans have been roasted until dark, the flavour can be damaged by moisture, light and especially by oxygen.
Roasting is one part art, one part science, and several parts judgment. It is a skill. Too much heat and the beans are roasted too dark and too much caffeol is burnt; not enough and the caffeol is not precipitated. In industrial quantities, the process is carefully controlled, but in smaller quantities, judgement is all. The higher the roast, the more uniform the resulting flavour.