The Royal Institution has created a great video explaining how do we came to create such intricate 3D models of complex molecules like those that make up proteins. The science and the astounding work behind x-ray cristalography is truly amazing.
X-rays are dangerous to humans, but if you use them in a clever way and beam them directly to a molecule, you can create a 3D map of that molecule by following the trails those x-ray leave on a screen. By matching up the trails the x-rays leave you can create a 3D model of the molecules.
The only pitfall: you can only map in this way molecules that can crystallize, meaning that can be packed together in highly ordered structures. When the x-rays are fired to these crystals they diffract on contact with the molecules leaving behind a diffraction pattern. Working back from that pattern you can discover the 3D form of those molecules.
The best place in UK to do x-ray cristalography is the Diamond Light Source, the synchrotron that generates beams of x-rays ten times brighter than the Sun.
How do they create those x-rays? They accelerate electrons in the 450 meter circumference accelerator to near the speed of light and, in certain areas where the ondulators are placed, the electrons are wiggled around vigorously and thus a powerful electromagnetic wave is created. That electromagnetic wave is in the x-ray band.
Knowing the 3D structure of molecules we learn how they interact with other molecules or we can create drugs that could bind with them much better. Or we could invent new proteins 😀
Why use X-rays? Because they have very short wavelength in thus can better interact with the atoms in a molecule.
See also how can you determine the structure of a complex molecule from a single crystal: