A 40 gallon leaves quite a bit of space for versatility when it comes to fish and fish species. YOu'll have quite a bit to choose from, even some that are less popular. The most common fish housed in a 40 gallon aquarium are Gruppies, Zebra Danio, Cory Catfish, Goldfish, Mollies, Betta, Three Spot Gourami, Banggai Cardinalfish, Bristlenose Pleco, and all sorts of Cichlids like Dwarf Cichlids, Firemouth or Peacock cichlids.  Besides these fish that can be combined, you could also choose to combine with plants, creating a paludarium if both kinds of species take about 50% each.