How does UEFA decide how many teams per league are allowed to qualify for the Champions League tournament?
@Martin shared a great reference in the comments.
The association ranking based on the UEFA country coefficients is used to determine the number of participating teams for each association...
It goes on...
For the 2019–20 UEFA Champions League, the associations are allocated places according to their 2018 UEFA country coefficients, which takes into account their performance in European competitions from 2013–14 to 2017–18.
Apart from the allocation based on the country coefficients, associations may have additional teams participating in the Champions League, as noted below:
(UCL) – Additional berth for UEFA Champions League title holders
(UEL) – Additional berth for UEFA Europa League title holders
In other words, countries with club that have continued success "reward" their league in the long run. For example, fans of La Liga or Spanish clubs have benefited from the success of Atletico Madrid, Barcelona, and Real Madrid for the last 6 years. This has guaranteed 4 spots for Spanish clubs in the Champions League.