He was formerly accused of being gay, which led to him being thrown into prison. In Malaysian law, having a gay relationship or homosexual sex can get people arrested and jailed. Anwar himself was only wrongly accused by some political opponent. He was never gay, only accused and slandered.
In the past, Anwar was associated with Malay nationalists, but later on he became more aligned with the leftist groups of the country, like Pakatan Harapan (Alliance of Hope). The King of Malaysia gave him a royal pardon, and he became popular among opponents of the ruling parties and against PAS, a conservative religious party.
He was one of the candidates to being Prime Minister, the others including Muhyiddin (the PM whose failures led to many Covid deaths) and Mahathir (built Malaysia with petroleum and rubber money, but also a bigot).
Of the three, the King chose Anwar, ending several suspenseful days caused by none of the main coalitions having enough seats in Parliament. Already people in Malaysia were worried that His Majesty would have picked the other two, dooming Malaysia to five more years of corruption.
I already hate PAS the most, because of its support for Taliban (which would kill nonbelievers and even modernised Muslims), treating us nonbelievers like blame things and garbage, and for its leaders being hypocrites and bigots.
In fact, many Muslims even see them as defiling Islam by their hypocrisy.