The Dwarves were created by the Ainu Aulë, who refused to wait for the coming of the Children of Ilúvatar, the Elves and Men. He secretly created the Seven Fathers of the Dwarves in a hall hidden under the mountains of Middle-earth.
Aulë could not create life, however, and he was disciplined by Eru Ilúvatar for what he did. After he realized that what he did was wrong, he let Ilúvatar decide on what would now happen with the Dwarves. Rather than destroying them, Ilúvatar decided to give them life instead. However, he did not want the Dwarves to Enter Arda before the Elves did, and ordered the Seven Fathers to rest underground until the Elves had awakened.
Of the races, Dwarves are the most resistant to corruption and influence of Morgoth and later Sauron. The Seven Rings of Power of the Dwarves did not turn them to evil, but it did amplify their greed and lust for gold. It is said that very few willfully served the side of darkness. Of those who did very little was written. Of the seven houses few fought on either side during The Last Alliance at the end of the Second Age, and it's known that none from the House of Durin ever fought on the side of evil. During the early parts of the Third Age (or at least in legends of the previous), it is known that in some places wicked Dwarves had made alliances with the Uruk. It is suggested by Tolkien in some of his notes that the Dwarves of the far eastern mansions (and perhaps some of the nearer ones) came under the shadow of Morgoth and turned to evil. It is however unclear if these refer to Dwarves beyond the Iron Hills (the most eastern known stronghold of the Dwarves).
Some of the Dwarves accused of fighting on the side of darkness may have been in conflict due to enmity between the races, due to misunderstanding (which may also apply to the Dwarves' distrust and hatred of the Elves), or enmity between the races caused by greed and envy (Men lusting after the wealth of the Dwarves and their handwork, and possibly between the Dwarven clans themselves), or by races becoming estranged from each other (the rise of enmity and distrust between Dwarves and Elves after the fall of Khazad-dum). What may have been self-defense may be seen as evil action by the opposing force. But in these cases, those involved were never allied with the enemy or their ambassadors (though the wars between the free peoples may have worked to his advantage). The trust and interaction between Elves and Dwarves was later restored through the friendship of Legolas and Gimli.