Habitat

NOTE: Some Habitats need help from your friends in order to be opened, like other buildings, as the Stadium. If you can afford (or don't have any friends), open them with Gems.

Habitat Optimization
As you know, there is only so much space on all of the islands to fit in all your habitats, Hatchery, Breeding Mountain, etc... That being said, this are is for brief speculation on your idea of the best habitats to have. For example, having 12 Large Dark Habitats wouldn't do you any good because you would only have one Dragon in each, so it would be wasted, but 1 Large Earth, 4 Large Fire, 4 Large Water, 2 Large Plant, 1 Large Electric, 3 Large Ice, 2 Large Metal, 3 Large Dark and 4 Legendary would give you a spread on everything. For the sake of the argument, stick to 28 Habitats max, since for 5 levels that is the max. Feel free to add.

Another way to optimize your habitats by lvl 26:

4 large dark (you'll have 2 open spaces.), 4 large ice, 4 large water, 3 large metal (2 additional spaces), 2 large fire (1 additional space), 1 large plant, 1 large electric, and 1 large earth (1 additional space). This will maximize the amount of gold you can collect and have spaces for every type of currently available dragon (except perhaps some of the no longer available ones like butterfly or seahorse). At lvl 26 you'll have space for 6 legend/pure habitats and at lvl 30 you can have 8 or you can use these spots for whatever additional habitats you want. Fill them in the above order as well. (All dark types in dark, all Ice types except for dark/ice in ice, all water types except for dark or ice/water in water, et al. Noted exceptions would be to put flaming rock and alpine in the Large earth habitat. Hope this helps!

If you desire to keep every single dragon once you arrive at all 73 non-pure dragons, the best layout would be 4 Legendary Habitats, (1 Legendary Dragon per habitat), 2 Large Dark Habitats (4 Dark dragon hybrids per habitat), 6 Large Ice Habitats (3 Ice dragon hybrids per habitat), 4 Large Water Habitats (3 Water dragon hybrids per habitat, 2 Large Metal Habitats (4 Metal dragon hybrids per habitat), 2 Large Fire Habitats (4 Fire dragon hybrids per habitat), 1 Large Plant Habitat (All remaining Plant dragon hybrids in 1 habitat), 1 Large Electric Dragon Habitat (All remaining Electric dragon hybrids in 1 habitat) and 1 Earth Dragon Habitat (Earth Dragon and remaining Electric/Earth hybrids).

The calculations are trickier once you include all 9 Pure Dragons as well. In theory, you could drop the number of Large Ice Habitats and Large Dark Habitats to 4 each which would allow the creation of 5 Pure Habitats, but it depends on the level of the Dragons and their surrounding boosts whether or not this will actually make you more gold in the long run.

another way is put all earth hybrids in 4 large earth habitats,same for others