The purpose of enlightenment is to eventually not re-emerge.
I think rather than punishment, it's more like a lesson. And dukkha is often mistranslated as "suffering", but in reality it's closer to dissatisfaction or unhappiness (sadness) rather than suffering.
I guess it depends on your personal outlook.
c.f. notions of transcending for other possible interpretations.
I always wonder if he would have advocated for suicide if only he didn't believe in rebirth.