This is explained in the body of the original Dune novel by Frank Herbert;
The Baron cannot forget that Leto is a cousin of the royal blood — no matter what the distance — while the Harkonnen titles came out of the CHOAM pocketbook. But the poison in him, deep in his mind, is the knowledge that an Atreides had a Harkonnen banished for cowardice after the Battle of Corrin.”
“The old feud,” Yueh muttered
and in its appendix;
VLADIMIR HARKONNEN (10,110—10,193)
Commonly referred to as Baron Harkonnen, his title is officially Siridar (planetary governor) Baron. Vladimir Harkonnen is the
direct-line male descendant of the Bashar Abulurd Harkonnen who was
banished for cowardice after the Battle of Corrin.
If you want to read about the genesis of the feud in more detail, Frank Herbert's son co-wrote a novel called "Dune: The Battle of Corrin" which covers the events that began the feud.
A story line followed throughout the novel is the relationship between
Vorian Atreides and Abulurd [Harkonnen] ...
Erasmus has placed two million captive humans in an array of cargo containers rigged to explode once the human fleet advances, called the Bridge of Hrethgir. Vorian believes that sacrificing the captive humans is a necessary loss, but Abulurd disagrees. The two argue until Vorian relieves Abulurd of his command and has him confined to quarters. In a final attempt to save the captives, Abulurd deactivates the weapons for the entire fleet, making the Corrin attack more difficult and dangerous and eventually causing much higher casualties. Unknown to either, the robot Erasmus disabled the human shield programming, saving the humans in orbit.
Following the victory, Abulurd is discharged and branded a coward by Vorian, though not branded a traitor like his grandfather Xavier, and banished from the League. After Abulurd is sentenced to exile on Lankeveil, his children hear stories about how their nobility had been stolen from them. When Abulurd dies of a fever, his sons claim it was Vorian Atreides who had brought the fever to destroy the Harkonnens. When House Harkonnen returns to the empire, their wild accusations at House Atreides are accepted as truth. Thus begins the feud between House Atreides and House Harkonnen.