This is why we have retakes. If your coursework results in lower grades than fellow students who cheated (with or without AI) there's no such recourse.
Even assuming all the students do it in good faith, there are factors other than knowing the material that can affect their performance on coursework. For example one person may have access to a well equipped, ergonomic, quiet space and plenty of undisturbed time in which to complete the assignment, while another may not.
The major benefit of exams is that everybody is taking them in, as far as possible, consistent and controlled conditions. It's not ideal, but I think it's better than the alternatives.
Some unis only allow retakes if you totally fail. They don't let you optionally choose to retake to try to do better, so no, that's not a solution that works for everyone.
Even assuming all the students do it in good faith, there are factors other than knowing the material that can affect their performance on coursework. For example one person may have access to a well equipped, ergonomic, quiet space and plenty of undisturbed time in which to complete the assignment, while another may not.
The major benefit of exams is that everybody is taking them in, as far as possible, consistent and controlled conditions. It's not ideal, but I think it's better than the alternatives.