I'm not really sure what the entropy represent. In wikipedia, they say that the entropy is the quantity of information available and is defined as $\mathbb E[\log_b P(X)]$ where $P(X)$ is the mass function of $X$. But I don't really get where this formula comes from... Can someone explain ?
For example, let take a box with $4$ red balls, 2 yellow balls, 1 blue ball and 1 green ball. The entropy is $\frac{7}{4}$. What does this mean ? And in my course, it's written that we encode red balls with $0$, yellow balls with $01$, blue ball with $110$ and green ball with $111$.
Honestly theses numbers comes from nowhere for me. When red has only one digit, yellow has two digits and green and blue has 3 digit.
Have a look at the book I recommended in the comments. It contains historical references, examples and many other useful results (including how the formula is/was derived).
On another note, if is helps, you can think of information entropy as a measurement of randomness (disorder or "missing" information). Let's look at the example in your question $$P(\text{red})=\frac{1}{2}, P(\text{yellow})=\frac{1}{4}, P(\text{blue})=P(\text{green})=\frac{1}{8}$$ and, as you calculated, the entropy of the random variable $X$ with possible values $V=\{\text{red},\text{yellow},\text{blue},\text{green}\}$ is
$$H(X)=-\sum\limits_{x\in V}P(X=x)\log_2{P(X=x)}=\\ -\frac{1}{2}\log_2{\frac{1}{2}}-\frac{1}{4}\log_2{\frac{1}{4}}-\frac{1}{8}\log_2{\frac{1}{8}}-\frac{1}{8}\log_2{\frac{1}{8}}=\frac{7}{4}$$
Indeed, $\frac{7}{4}$ may not say a lot at this point. But, imagine (another random variable $Y$) having $8$ balls, $4$ pairs of the same color each. Then
$$P(\text{red})=P(\text{yellow})=P(\text{blue})=P(\text{green})=\frac{1}{4}$$ and $$H(Y)=2$$ In this case, $2>\frac{7}{4}$ or $Y$ has "more randomness" (or more disorder) than $X$. This makes sense because, for example, you can't predict "red" with $P(\text{red})=\frac{1}{2}$ anymore. Or you don't have enough (or miss) information to predict the state of $Y$.
And finally imagine (a random variable $Z$) having $8$ balls of different colors. Then $$P(Z=\text{color}_i)=\frac{1}{8}$$ and $$H(Z)=3$$ In this case $3>2>\frac{7}{4}$ or $Z$ has higher entropy because it has more states ($8$, compared to $4$ states of $Y$).
Three important properties of entropy to remember are: