There are 2 main ways to earn gold. The first is probably the most known way: Collecting from habitats.
But it isn't as easy as it sounds: some dragons have a better earning rate, but can only stay in habitats with a low max gold amount.
The best way is to combine some dragons with high earning, low max with dragons with low earning, high max.
The best dragons of each element are:
Earth: Earth, Star and Poo Dragon (15)
Fire: Laser Dragon (12)
Water: Poo Dragon (15) (, Coral Dragon (12))
Plant: Tropical, Coral and Gummy Dragon (12)
Electric: Star Dragon (15)
Ice: Alpine Dragon (10)
Metal: Armadillo Dragon (14) (, Battery Dragon (9))
Dark: Poo Dragon (15) (, Hedgehog Dragon (13))
Legendary: Legendary Dragon (60)
Feeding dragons makes them earn more, so have always something running in your farms if you are level 10+!
What can also helps your income are boosts. They are a good investment if you have some spare gold (and a high level), and smartly placed they can make a huge difference.
The second way is to sell dragons. The best dragon to sell is the Jade Dragon (Plant+Metal) because it has a very low breeding time and earns 100K gold.
If you go to sleep, start breeding something else, like Medieval Dragon, which sell for 200K.