Coffee beans get oily when they have been roasted beyond the point where the cell walls rupture and the oils stored inside the cell wall vacuoles are released. During the roasting this stage is marked by a cracking noise called the second crack. The first crack happens at a lower temperature when the water in the bean turns to steam.
If the roast is very dark i.e the beans are a dark chocolate color or darker, the oil will be on the bean from the day of the roast and stay there until it is about 3 to 4 weeks old, at which point it will all have evaporated. Beans this color without oil can be a warning that the coffee is stale. If the roast is a bit lighter, milk chocolate color, the oil will take about 3 days to a week to appear on the bean surface. In parts of Europe, that like this level of roasting, the saying is that a bean without oil is either too old or too young. Beans lighter than milk chocolate have intact cell walls and will never get oily, so will not provide any indication of the freshness or otherwise of the bean.
Are oily coffee beans better?
Advocates of lighter, oil-free roasts claim oily beans taste rancid. Advocates of oiled roasts say that without them appearing through roasting, the oils cannot get into the cup, since grinding alone will leave most of the bean cell walls intact. There is truth to both these statements, and in terms of the flavors in the coffee oils, a medium, milk chocolate roast, fairly new, and just showing a few spots of oil, will taste the best.
However, not all things are equal. The darker one roasts the coffee beans, the more one roasts out the fruit and floral flavors in the coffee. On the other hand, very dark roasts have spice and smoke flavors that many people enjoy. These flavors have nothing to do with the oils.
People who make a hobby of espresso, will probably never willingly drink a coffee whose beans are so oily that they foul the grinder. Coffee beans that are oily can be good, but generally oily beans are one indication of over-roasting, poor storage, or age. Low quality beans are often over-roasted to a dark, oily state because it is the only way to burn off their natural flavor so that they become drinkable ( e.g. Vietnamese Robusta - there you get your choice of a rubber taste, or a burnt rubber taste).
Generally, you cannot take "oily beans are bad" as a rule— but much like the "Golden Rule," it is a good guideline.
What are the things that make a good cup of coffee?
There are 3 main parts to making great coffee,
The coffee bean and how its been roasted, the coffee grinder and the coffee machine. Each one contributes to the overall aroma and flavour of the coffee. Without a good coffee bean, the coffee will taste poor and reflect the quality of the bean. Without the correct grinding, even a good coffee bean will not produce the flavour that it should. Without a good coffee machine, extracting the true flavour from the coffee will be very difficult.
What are the different roasts?
Light roasted coffee. A very brief roasting process yields a pale reddish-brown hue to the coffee beans. The beans will have an aromatic, clear, mellow flavor. The smooth flavour belies a high caffeine content. Most lighter roasts will have as much if not more caffeine than a dark roast bean.
Medium roast coffee. These beans are baked a bit longer, yielding a rich-brown colour with a deeper and more aromatic flavor than light roasts, however, they will have less edge than darker varieties but also will have less bitter qualities. They're complex, fragrant and flavorful.
Dark roast coffee. The beans are baked to a deep, glossy brown or black. This makes up most espresso coffees. The most popular of these are Italian and French roasts. Dark roasting must be done with great attention and care. It's easy to over cook the beans making them smell and tastes burnt. More of the caffeine within the bean is cooked off, hence espressos coffees include robusta beans which are higher in caffeine to give the espresso the kick people expect.