This seemingly suicidal behavior is actually a clever survival strategy. The minnow's chemical has two distinct functions. First, it warns other minnows about the danger. Minnows travel in schools with close relatives, so this chemical alarm warns the others away from potentially dangerous waters. Even if the original minnow is eaten, its brothers and sisters will live to reproduce. From a genetic standpoint, this self sacrifice makes sense.
You might wonder about the chemical's other function though--to attract more pike. A minnow's skin is most likely to be damaged in an attack from a relatively small pike. Larger pike simply swallow their minnows whole. Because of this, the alarm substance is usually released when a small pike is attacking. This means that the chemical might well attract pike that are larger than the minnow's current assailant. Pike have no qualms about eating other pike, so if a big one sees a smaller pike chasing a tiny minnow, that big pike will go after the larger mouthful, allowing the minnow to escape.
It's much like the end of Jurassic Park. The humans were about to be eaten by evil velociraptors, when the noise of their struggle summoned a bigger predator: Tyrannosaurus Rex. T-rex ate the raptors, allowing the humans to escape.