Researchers who use experiments to test something must use random sampling techniques to choose who will take part in their experiments. This means choosing people entirely randomly - so that each person in the target population has an equal chance of being chosen to take part in the experiment.
Random sampling enables researchers to select a sample that represents the target population. This allows the researchers to generalize: They can say that the results of their research apply not only to the small group of people who took part in the study - their results also apply to the target population.
Randomized Controlled Trials (RCTs)
The goal of most RCTs is to see if a specific treatment makes a difference to people receiving it. To test this, researchers have to do experiments to compare results: Did people who got the new treatment do better than people who got the old treatment or no treatment at all?
Is it enough to just have groups that get different treatments? No. Each person who participates in the experiment should be selected randomly, and then randomly be placed in either the control group or the experimental group. This will help to eliminate possible additional differences between people in these groups - differences caused by other factors, not by the treatment.