By chance.
Ancient multicellular organisms were small and did not require an oxygen distribution system.
As their sizes increased, animals developed gills and a fluid began to circulate throughout their bodies.
With further growth, there arose a need for respiratory pigments that enhance the oxygen-carrying capacity of the blood.
The "working tools" of these pigments became metal atoms, as they easily bind and release oxygen. The choice of metal was likely the result of a random mutation.
In mollusks and crustaceans, these turned out to be proteins that "work" with copper (hemocyanin, which is blue), while in vertebrates, they work with iron (red hemoglobin).