How do I go about cleaning up the corruption in Riften?
There are a number of things behind the state of Riften: some are solvable, others are Riften-by-design. Riften is full of grays, and you might have to modify your definition of "success" while trying to improve the state of things there.
Dealing with the Skooma trade
Riften's full of junkies. You can help them get above the influence by disrupting the Skooma trade in the Rift (adapted from my answer about getting a house there):
- Speak to Wujeeta and completed "Helping Hand" by giving her a healing potion.
- Intimidate Wujeeta into telling me where she got her Skooma
- Speak to Jarl Laila in Mistveil Keep and tell her who the dealer is, and accept her request to shut him down
- Go into the Riften Warehouse, confront the dealer, and retrieve the information about where the Skooma is coming from
- Tell the Jarl about the source, who then will tell you to deal with it
- Go north to Craigslane Cavern and dirupt the Skooma operation by killing everyone inside and outside
- Report back to the Jarl about the disruption.
Improving the quality of life of the citizenry
With all the worrying and fretting about their conditions in Riften, a lot of citizens just need a helping hand. Ask around and see if you can help people out: by completing miscellaneous objectives, people tend to act a little more up-beat.
The Honorhall Orphanage
The head of the orphanage, Grelod the Kind, does not live up to her name. She keeps the orphans in a state of fear and is all around not a good person. You can think of the little children and confront Grelod:
At some point, you'll get a rumor about a boy potentially summoning things in Windhelm. When you go to investigate, he's actually trying to call the Dark Brotherhood to put out a contract on Grelod the Kind. Should you accept, you can kill her, and everyone in Riften will thank you for it, or at least turn a blind eye to your wanton murder.
The Thieves' Guild
There's a certain group Riftenites who are also down on their luck: the Thieves' Guild. Once an establishment to be feared across Skyrim and Tamriel, it's now been reduced to a gang of petty thugs and criminals.
You can get them back to their former glory by helping them take care of business and eradicate their competition in the Rift. You might run into Brynjolf during your time in Riften, who will begin the quest chain for them.
You can also help their main benefactor take over the Rift during the Civil War:
if you side with the Imperials, Maven Black Briar will become Jarl of the Rift
Certain parts of Riften are clean-able, but the Thieves Guild and Black Briars are here to stay.
There are actually some quest lines which require that the player become a part of and contribute to this component of Riften's corruption, whereas there are not really any options for the player to productively work against it.
See @MarkTrapp's answer for more clarification of what you can do to help the Riftenites.