It waswasn’t illegallegal
At least, outside an official trial by combat.
Duelling arrived in England from Italy sometime in the 1570s and it was outlawed by Elizabeth I in 1571 - quite possibly before any duels were ever fought there.
If you want to know why they happened despite their illegality, the answer is economics - people will do all sorts of things if they believe the rewards outweigh the risks.