Welcome to Tropical Fish Keeping forum. Glad you joined us.
Yes, a 40g will be fine for the gourami, and you can add some compatible fish. Just one word of caution: if the two gourami are males, trouble will almost certainly ensue. Gourami males are territorial, and although it can vary from fish to fish, many of the males consider the tank (whatever its size) as their personal domain and will fight and kill any rival. And the Blue Gourami and Gold Gourami are actually the same species, just different colour variations. If they are females, there shouldn't be an issue. If one is male and one female, probably fairly safe, although male gourami have been known to kill a female. I cannot see the fish well enough to identify the sex. You can read more about this fish in our profile, click on the shaded name to pop up the profile. It will also suggest suitable companion fish.
To the 5g, no that is not sufficient space for the Zebra Danio as this is a shoaling fish and should be kept in larger groups, at least six. Shoaling fish occur in large groups out of security, but they also often have interactions among fish in the group, and if there are not more of them they can be stressed, and this can bring out increased aggression even in otherwise "peaceful" fish. More on this also in the profile. The 20g with another 3 would be better. Zebra Danio are not the best fish for gourami for the same reason you mention--their activity. Gourami are sedate fish that like to cruise among floating plants. Which brings me to the plant issue.
It would be very good to get some plants for your 40g. Floating plants are ideal for gourami, and even something as simple as stem plants allowed to float works. I won't get into the planted tank topic here, but you can read more in the series "A Basic Approach to the Natural Planted Aquarium" at the head of the Aquarium Plant section of the forum.