Is that why excommunication was such a big deal before the 20th century? Because you go to hell if you're kicked out of the church?
Excommunication is a big deal now.
The fact is, any serious sin excommunicates just by its nature and therefore condemns the sinner to hell. In order to reenter into communion with the Church one needs to go to confession and repent of his sin.
Public excommunication is necessary when the sin is grave, the sinner is obstinate in his sin, and it is public. That is so because it then causes others to sin similarly. Typically, that is done to heretics, — people who teach stuff contrary to the dogmas of the Church.
Note that this is done for the benefit of the sinner as well as for the benefit of those he might lead into sin. The excommunication draws his attention tot he gravity of his offense and hopefully, will lead to him recanting of his error and restoring his communion.