Let's think about several "why" questions concerning the genetic code.
1. Why is the code based on reading 3 nucleotides, rather than 2 or 4?
The answer is probably because 3 gives enough codons to code for the 20 or so different amino acids used to make proteins. A code based on reading two nucleotides could specifiy a maximum of 15 amino acids, plus one stop codon. This almost works, and the specifics of the code suggests that the "two nucleotides" scenario is related to how the code evolved.
2. Why is the code "universal", i.e., the same in all organisms?
The answer is probably because the code evolved early and got fixed. That is, the universality of the genetic code is a strong argument at the molecular level that all forms of life today are descended from one ancestral form. Early on, there may have been various versions of code, but all of these died out.
3. Why does ( for example) UCG code for serine, rather than for some other amino acid?
We do not know the answer to this question. As we have seen this semester, we do know that there is a specific aminoacyl-tRNA synthetase that hooks serine (and only serine) onto the tRNA that can bind to the UCG codon. So, in some sense that is why UCG codes for serine. But we don't know the events of several billion years ago that made it turn out this way.
Is it possible that the codon assignments are random? Analyses in recent years have suggested that this is not the case. When all possible point mutations are considered, it turns out that the code is about the best possible at minimizing the change in hydrophobicity of the coded for amino acid. Further analyses such as these might, just might, eventually lead to a solid answer to question 3.
So, we see that questions about why the genetic code is the way it is are really questions about the origin (and early history) of life on earth. For some of these questions, we have reasonable answers. There remain, however, significant mysteries about how the code evolved, and it is not clear whether we will ever have be able to "see" all the details of the events several billion years ago that gave rise to the code. The roles played by probability and contingency might remain hidden from us.