Diamonds form from carbon atoms under extreme temperature and pressure some several hundred miles below the Earth's crust in the mantle. Then some 100 million years ago subjected to rapid gas expansion they had been delivered through the Earth's crust onto the surface where we are able to mine for them. That is how.