Events in order.
1. Rin was kidnapped by the mist and made into the Sanbi's Jinchuuriki.
2. Rin killed herself by jumping in front of Kakashi's Chidori later on.
3. Sanbi was revived elsewhere.
4. Probably sealed into Yagura
5. Then Obito came along and controlled him.
But the only thing that doesn't make sense is that later on Obito himself, along with Deidara captured the Sanbi...in the wild. If Obito (Whose ambition was collecting all the Bijuu for the Moon Eye Plan) was controlling Yagura while he was a Jin, that means the Sanbi should have been pretty much captured by Obito, but that wasn't the case. So maybe Obito controlled him before he became a Jin, and then abandoned his control of him, leading to Yagura becoming a Jin later on, dying somehow and then Sanbi was revived in the wild.
Or maybe Obito killed off Yagura after he was finished using him and let the Sanbi revive into the wild so he could capture him later on, as he would be weakened from not having a host and because they need to seal the Bijuu in numerical order otherwise the Mazo would shatter. I think this is the most likely scenario so Obito most likely did control Yagura as a Perfect Jin.