Hi Alex. The reason why we use the rule with the uniform distribution is that, whenever we want to recreate randomness with a computational algorithm, we deal with the fact that those algorithms are deterministic by definition, hence they won’t be able to perfectly recreate randomness. The assumption we make in this topic is that generating random variables from a Uniform distribution is the only source of randomness we can use, hence we use it as a ‘support’ for any other random sample/number we want to generate.
The reason why we first compare ‘u’ with sunny is that, in our probability distribution vector mu, the first component is sunny, but it was an arbitrary choice! You can see sunny, rainy and cloudy as x, y and z. The rule is simply an algorithm we use to replicate randomness starting from a support which is our uniform distribution.
I hope I answered your question! Do not hesitate for any other doubts/curiosity