A Chance Arrangement

It is given by Brynjolf, at the town square in Riften or in The Bee and Barb and is the initiation quest to join the Thieves Guild.

Walkthrough
The quest begins once Brynjolf speaks to the Dragonborn, when first entering Riften, and the Dragonborn has the choice to help him. Brynjolf can initially be found during daytime or nighttime. He can be most commonly found in The Bee and Barb or walking around the marketplace.

Stealing

 * When the Dragonborn tells Brynjolf they are ready to get started, Brynjolf will call everyone over to him. He starts telling people about some valuable potions he is selling for 20 septims. Wait until everyone is distracted and not moving anymore, listening to Brynjolf. The ring is found in Madesi's strongbox, located underneath his booth behind a locked sliding door. Note that this is different from the display case on his stand. The Dragonborn may choose to either pickpocket a key from Madesi or pick the lock. The sliding door and lock may be unlocked the night before when there is less people around. Steal the ring, along with other items, then sneak over to the crates behind Brand-Shei.
 * Pickpocket Brand-Shei, but instead of taking from him, plant the ring on Brand-Shei. He's sitting down watching Brynjolf talk and is easily pick-pocketed from behind the boxes with a high success rate. Brynjolf should stop the distraction once this is completed, and, after turning in the quest, Brand-Shei will be approached by a guard and arrested. Planting the ring on someone else does not get the person arrested instead.
 * Talk to Brynjolf again, and he will congratulate the Dragonborn.

Not stealing or failing
Failing to complete the assignment does not prevent the Dragonborn from continuing the quest line. Brynjolf will express disappointment, but will state that he believes the Dragonborn still shows potential. It should be noted that failing to plant the ring on Brand-Shei will have the bonus of preserving him as a vendor with gold supply. This may be advantageous to a lower level character, or anyone without higher level speech perks. The following scenarios are possible: In any scenario above, the Dragonborn will return to Brynjolf without getting paid and continue the quest-line while keeping Brand-Shei as a vendor.
 * Getting caught stealing during the distraction will result in failing the quest. If the Dragonborn has earned the title of Thane of Riften, they can use this title to get out of being caught during this quest, though it may not be recommended since thanes only get one pardon.
 * The Dragonborn can remove Madesi's ring from their inventory anytime after stealing it, and tell Brynjolf that it was lost. The "Plant Madesi's Ring" objective gets marked as failed, but the mission can still be completed, allowing the Dragonborn to continue and join the thieves guild.
 * The distraction will go on for quite some time, and if the Dragonborn doesn't plant the ring on Brand-Shei before Brynjolf finishes, the group will sit in silence sometimes until the quest is completed. The quest will fail after some amount of time, however. Leaving Riften and going to the stables once and returning may still have the distraction running, but after leaving a second time the quest may end in failure. If this occurs, Brynjolf will express disappointment, as noted above, saying that he could not keep up that distraction for too long, but the quest line will still be available.
 * Another way to complete this quest quickly and safely, without breaking any laws: After the distraction starts, simply wander around and go inside any door around the market. This will cause the planting assignment to fail, while strangely, the stealing assignment will still be completed. In this manner the Dragonborn can still complete the quest by talking to Brynjolf without any stealing or pick-pocketing. This will not result in breaking the questline.

Trivia

 * If the Dragonborn has a follower, the follower may mingle with the rest of the crowd. The follower will follow them again once the crowd disperses.