There are a few legitimate ways to get a Master Ball in Pokémon Diamond and Pearl without cheats or the lottery.
The most common method is that Cyrus gives you one after you defeat him in Veilstone City, he simply hands it over. You can also obtain one by transferring over a Pokémon that naturally holds it and encountering it in the wild. Finally, there is a cloning trick involving Double Battles that lets you duplicate an item like a Master Ball.