Many people believe Snape is very nasty towards Neville because Neville could have been the Chosen One or because his parents were aurors, but I don’t agree with those headcanons.
Neville is a traumatised boy. His parents were tortured so badly that they lost their minds. He’s grown up without them with a very strict grandmother as his guardian. His family is an old pureblood family and while they are against the pureblood ideology, they still expect a lot from their heirs. Neville’s parents’ fate most likely only increases pressure put upon him. Neville’s uncle almost killed him to squize some magic out of him, as if saying that it’s better to be dead than a Squib. Neville got his father’s wand instead of the one who chose him, as if being told that he had to be like his father, even if he’s just a sad, scared child.
All that turns Neville into a soft version of Obscurial. He doesn’t fully control his magic. We see it especially during the Potions lessons. At the very first lesson Neville somehow turns his potion into a very corrosive substance that melts his couldron and forces his classmates to climb on their desks. Later in the fourth year we hear that he melted six couldrons during about three months. Neville believes himself to be almost a Squib, but he’s very powerful. All the other students who don’t always succeed in Potions only manage to make some too watery or too thick fluid of the wrong colour that simply doesn’t work, doesn’t do anything.
I can imagine Snape having nightmares about Neville with a melting couldron, surrounded by poisonous fumes, killing Harry Potter and Draco Malfoy and all the other students, because Snape hasn’t managed to make him understand. Those lessons must be terrible for him. In this class there’s Harry Potter who looks like his father that used to bullied Snape, who is disobedient and inattentive, and whose presence reminds Snape of his enormous guilt. There’s also Draco Malfoy who tells his family everything and who has to believe Snape is on his side like a good Death Eater, so that in the future his influencial father can be his witness before Voldemort. There’re also Crabbe and Goyle—also sons of Death Eaters. It’s already very stressful and then there’s Neville with his dangerous potions that can kill everybody in a minute.
Snape doesn’t know how to deal with someone like Neville. Snape has no pedagogical education, no experience. He learnt how to teach by imitating his own teachers who finished school in the first half of the 20th century or even in the 19th century. About a decade before Snape started teaching, physical violence was still allowed as a punishment at Hogwarts.
It’s worth noting that Snape doesn’t take points from Neville and he only gives him one detention after he melted six couldrons.
So what Snape does to Neville is deeply wrong and very misguided but it’s just an attempt to teach him Potions. It doesn’t stem from malice or personal revenge.
And we know it, because when Snape begins to teach DADA—after Neville was encouraged by Lupin, after he learnt much in the Dumbledore’s Army, after he fought in the Ministry, after he got his own wand, after he gained a lot of confidence in his magical abilities—Snape doesn’t bully Neville. It proves that it was a matter of Neville’s performance at Potions, nothing more.