States tend to restrict freedom of speech for several reasons:
- Prevent harm to individuals by defaming speech (insults, defamation)
- Prevent harm to individuals by malicious misinformation (fraud, false advertising or the classic example of "shouting fire in a crowded theater")
- Prevent harm to the values of society or to the development of minors by obscene speech (censorship of pornography or glorification of violence)
- Prevent harm to whole groups of the population by agitation and calls to violence
- Prevent harm to the public order by speech which undermines the authority of the government
And these are just some examples.
In all these cases, there is an assessment of the personal right to freedom of speech vs. other rights which could be violated or damages which could be caused by said speech. Freedom of speech is not the only fundamental right guaranteed by most states. States are often also obligated to provide personal safety, human dignity, property rights, equality, equity, rule of law, public order and many more. There will always be cases where two fundamental rights conflict in each other. So no fundamental right is absolute. In such cases, the state has to find a compromise. Which means one fundamental right must be limited in order to preserve another.
Different states make these compromises very differently, depending on their ideological values and political circumstances. Some countries, like the United States for example, are very lenient when it comes to speech undermining the authority of the government. Other countries, like the People's Republic of China for example, are a lot more strict in that regard and will suppress any open criticism of the state.