Phonemes are groupings of phones (different sounds), which language speakers treat as equivalent.
The phones that are variants of the same phoneme are allophones of the phoneme.
Normally, the distribution of allophones depends on their context: there is a rule, based on surrounding phonemes, which determines whether one allophone or the other is used.
If you can’t work out such a rule, then you give up and say that the choice of allophone is random. (Or at least, it’s random phonologically: there may be other factors at play, such as sociolinguistics.)
If the distribution of allophones is not phonologically predictable, then the allophones are in free variation.