You would use every possible variation of an independent variable. In the vast majority of cases, this is not feasible, so a representative group is chosen to reflect the whole population.
For any experiment, you may be criticized for your generalizations about sample, time and size.
You must ensure that the sample group is as truly representative of the whole population as possible.
For many experiments, time is critical as the behaviors can change yearly, monthly or even by the hour.
The size of the group must allow the statistics to be safely extrapolated to an entire population.
In reality, it is not possible to sample the whole population, due to budget, time and feasibility. (There are however some regional large scale-studies such as the HUNT-study or the Decode Genetics of Iceland-study)
For example, you may want to test a hypothesis about the effect of an educational program on schoolchildren in the US.
For the perfect experiment, you would test every single child using the program, against a control group. If this number runs into the millions, this may not be possible without a huge number of researchers and a bottomless pit of money.
Thus, you need to generalize and try to select a sample group that is representative of the whole population.
A high budget research project might take a smaller sample from every school in the country; a lower budget operation may have to concentrate upon one city or even a single school.
The key to generalization is to understand how much your results can be applied backwards to represent the group of children, as a whole. The first example, using every school, would be a strong representation, because the range and number of samples is high. Testing one school makes generalization difficult and affects the external validity.
You might find that the individual school tested generates better results for children using that particular educational program.
However, a school in the next town might contain children who do not like the system. The students may be from a completely different socioeconomic background or culture. Critics of your results will pounce upon such discrepancies and question your entire experimental design.
Most statistical tests contain an inbuilt mechanism to take into account sample sizes with larger groups and numbers, leading to results that are more significant.
The problem is that they cannot distinguish the validity of the results, and determine whether your generalization systems are correct. This is something that must be taken into account when generating a hypothesis and designing the experiment.
The other option, if the sample groups are small, is to use proximal similarity and restrict your generalization. This is where you accept that a limited sample group cannot represent all of the population.
If you sampled children from one town, it is dangerous to assume that it represents all children. It is, however, reasonable to assume that the results should apply to a similar sized town with a similar socioeconomic class. This is not perfect, but certainly contains more external validity and would be an acceptable generalization.