There are two things to consider here. Firstly, a stiff sole offers great support to the foot and optimal power transfer so if riding fast and hard is your goal, a stiffer sole is the way to go which is why carbon- and nylon-soled shoes are popular with cross-country riders and racers.
However, if you’re going to need to walk, hike-a-bike, or push up climbs a more flexible sole will make that easier, and it will also allow the foot and the shoe to curve into the pedal more for added grip, particularly important for flat pedal shoes.