This is a great question. The answer is, with a looooooot of hard work and research, and even then there are a lot of things for which we currently do not know the cure.
It is important for scientists to collaborate and share knowledge. Groups of people with different expertise each contribute to finding cures. For example, a molecular biologist may pinpoint the cause of a disease, with the help of geneticists and synthetic biologists (who work on computers). Then even more scientists have to work together to create a possible treatments – medicinal chemists are important here, formulation scientists help to format the medicine in the best way (such as a liquid medicine or a tablet), and then pharmacologists may research the impact of the medicine on the body.
This is a very simplified example – in reality, from the whole process of finding a cure can take decades and hundreds (if not thousands) of people!