Why do several (if not all) parametric hypothesis tests assume random sampling? Tests like Z, t, and several others assume that the data is based on a random sampling. Why?
Suppose that I'm doing experimental research, where I care much more for the internal validity than the external one. So, if my sample might be a little bit biased, okay, as I've accepted to not infer the hypothesis for the whole populations. And the grouping will still be random, i.e., I'll choose for convenience the sample participants, but I will randomly assign them to different groups.
Why can't I just ignore this assumption?
 A: In real scientific research, it is quite rare to have data that came from true random sampling.  The data are almost always convenience samples.  This primarily affects what population you can generalize to.  That said, even if they were a convenience sample, they did come from somewhere, you just need to be clear about where and the limitations that implies.  If you really believe your data aren't representative of anything, then your study is not going to be worthwhile on any level, but that probably isn't true1.  Thus, it is often reasonable to consider your samples as drawn from somewhere and to use these standard tests, at least in a hedged or qualified sense.  
There is a different philosophy of testing, however, that argues we should move away from those assumptions and the tests that rely on them. Tukey was an advocate of this.  Instead, most experimental research is considered (internally) valid because the study units (e.g., patients) were randomly assigned to the arms.  Given this, you can use permutation tests, that mostly only assume the randomization was done correctly.  The counterargument to worrying too much about this is that permutation tests will typically show the same thing as the corresponding classical tests, and are more work to perform.  So again, standard tests may be acceptable.  
  1. For more along these lines, it may help to read my answer here: Identifying the population and samples in a study.  
A: Tests like Z, t, and several others are based on known sampling distributions of the relevant statistics. Those sampling distributions, as generally used, are defined for the statistic calculated from a random sample. 
It may sometimes be possible to devise a relevant sampling distribution for non-random sampling, but in general it is probably not possible.
A: If you are not making any inference for a wider group than your actual sample, then there is no application of statistical tests in the first place, and the question of "bias" does not arise.  In this case you would just calculate descriptive statistics of your sample, which are known.  Similarly, there is no question of model "validity" in this case - you are just observing variables and recording their values, and descriptions of aspects of those values.
Once you decide to go beyond your sample, to make inferences about some larger group, then you will need statistics and you will need to consider issues like sampling bias, etc.  In this application, random sampling becomes a useful property to assist in getting reliable inferences of the wider group of interest.  If you don't have random sampling (and you don't know the probabilities of your samples based on the population) then it becomes hard/impossible to make reliable inferences about the population.
