When cocoa (the powder) was introduced in Europe, hot cocoa became an extremely popular drink. Due to this popularity large amounts of cocoa butter became available, since the butter was also part of the cocoa bean that cocoa was made out of but wasn't used. In 1847 a new product was developed that contained sugar and also extra cocoa butter so that it had a better consistency than the 'natural' proportion cocoa/cocoa butter showed. This was the first chocolate.

Two Swiss improvements in around 1880 led to the milk chocolate as we know it.

To make chocolate, the cocoa bean is first cleaned, fermented, roasted, and the skin removed. The cocoa mass (= bean minus skin) is neutralized and ground. Part of the cocoa mass is pressed, so that the cocoa butter is separated from the cocoa.
Part of the cocoa butter is added to the unpressed cocoa mass, as well as other ingredients like sugar, milk powder and vanilla. The mixture is then mixed for a long time, a process that involves large rolls. The longer this process takes, the better the structure of the eventual chocolate, and thus the quality, becomes.
After the rolling process the chocolate is conched, a process that is like the mixing process but with slighly elevated temperature. After several hours some more cocoa butter is added and some lecithin (an emulsifier). The conching takes 12 to 72 hours.
Finally the chocolate is poured into metal moulds and cooled. Voila! Chocolate.