It's kinda the underpinning of the whole film that Jack just wasn't ok mentally. He 'had it all' but there was just an inability for him to be at peace and stable in the world he lived in.
We first see him on film immediately drinking after his concert, he does drugs throughout the film. He has an upturn when he meets and marries Ally. But it's hinted at throughout the film that he had a lot of demons from his childhood, like the fact that his father was a raging alcoholic who he idolized because he was the only parent around and he was supposed to, most likely, isolated away on a farm. Jack mentions however it was bobby he idolized really, but Bobby in Jacks early years was always out at gigs trying to make something of himself (jack father had him in his 60's, Bobby probably in his early 20's), given Bobby was like at least 20-30 years older then Jack. Jack mentioned that when Bobby had left once when he was 13 that's when he tried to kill himself, and that the ceiling fan he'd tried to hang himself via had sat there broken for months (probably when Bobby came home). It must of been pretty fucked up for Bobby as well to feel like he was basically being surrogate parent to his younger sibling.
As for why he had to commit suicide. The character, just couldn't handle life and his demons, likely knew that he was always going to be the way he was, some people will never change. Perhaps he knew he was on his way out career wise, Ally was on the up and up per how she was being marketed, and that the downward spiral of himself would only drag her down like a rock.
I do hate that they made Ally transform into a pop persona, the plot could have worked easily without the pop star stuff, but it's more relevant today and an easier vehicle for the conflict i guess (Jack being staunchly country rock while Ally could do whatever marketed her best, similar to Lana Del Rey and Lady Gaga herself)