In Naruto, it was said that you need both Senju and Uchiha DNA to achieve Rinnegan, right? So why didn't Danzo get Rinnegan? He had Senju DNA holding Uchiha DNA.
Well, that's becasue you also need to be competent enough to master both these powers.
Madara was strong enough, and was able to awaken it. Danzo however, was not.
Danzo's DNA originates from experiments and body modifications. He wasn't a "Natural", while Madara had natural mastery over the Uchiha powers, and after being defeated by Hashirama, mastery over the Senju powers.
It was also implied that you need to be very close to the end of your lifespan to awaken the Rinnegan.
Edit - Spoilers!
Based on the recent chapters, it is implied that it isn't Senju + Uchiha which is needed to awaken the Rinnegan, but Indra's and Ashura's (Sage of Six Paths' sons) chakras. That is why Madara (the incarnation of Indra) was able to awaken them after implanting Hashirama's (the incarnation of Ashura) cells into his wounds.
Danzo was not able to awaken the rinnegan because he had senju DNA and Uchiha eyes but had neither enough chakra to effectively utilize either ability (hashirama' s wood style or the sharingan in his arms). While madara was an Uchiha who implanted hashirama's DNA throughout his whole body he did not awaken the rinnegan until he was near death. It would not be expected for someone like Danzo to be capable of manifesting the rinnegan, at least at the point in time that he was living.
Like many said, you kinda need the "blood" or "chakra" of the Uchiha and Senju to awakened, which many stated to be implied at the end of one's life. Danzo doesn't have any, only body modifications. Danzo had the Sharingan because he STOLE them, he ripped them out of the Uchiha who had them, therefore he will never awaken the Rinnegan. That's why he was bandaged, so it doesn't drain his chakra. It's not that Madara was strong enough, he basically had the requirements to do so, just at the end of his life did it awakened.
Nagato was implanted the Rinnegan at a early age by Madara before he died, and Nagato is of the Uzumaki, hence how he could easily handle the Rinnegan (I am sure if he had both Rinnegan or just the one).