Complex evolutionary processes maintain an ancient chromosomal inversion