I do not believe in free will, and therefore I believe that criminals were doomed to commit a crime. There is no point in causing them suffering simply for the sake of punishment, just as there is no point in beating a stone that has fallen on you. Well, maybe just for fun.
Yes, the fear of going to prison will deter other people from committing crimes, but in this regard, allowing suicide will not change anything. The vast majority of people do not want to die and the fear of going to prison will not reduce the possibility of committing suicide there.
From this point of view, I don't see anything against prisoners having the opportunity to commit suicide. What is the most important purpose of imprisonment? Eliminate a dangerous element from society. Suicide will deal with this even better.
Another thing is that ordinary people should also have this opportunity.