There are lots of reasons why people can be toxic in Minecraft. Maybe they are just very competitive as a person which makes them being proud when they win and mad when they lose. Some people don't always realize that there are living human beings with feelings behind online accounts, so they say whatever they feel like because they don't know that person anyway. Some people have frustrations and emotions from real life events which they express online because maybe they can't express them in real life or they are easily triggered because of the stuff that's on their mind. I know that online gaming and chatting is an escape from reality for a lot of people, and you often don't know who's behind an in-game character and you don't know what's on their minds and what's going on in their lives. These things have an impact on their behaviour, and you can't always blame them for that. There are probably way more reasons behind toxicity, these are just some examples.
There will always be toxic people, like said above, and the best thing you can do is just let them be. You can't change them.