Hemoglobin has the ability to attract and hold oxygen where oxygen is plentiful, and to attract and hold carbon dioxide where it is more plentiful. As such, it obtains oxygen in the lungs, and then carries it through the bloodstream to individual cells, where carbon dioxide is more plentiful. The hemoglobin gives up its oxygen in this environment and absorbs the carbon dioxide. The process is reversed when the blood returns to the lungs.
Unfortunately, hemoglobin binds very well to carbon monoxide, and when it binds the molecule is less receptive to both oxygen and carbon dioxide, meaning the hemoglobin becomes useless to carry either. This is the mechanism that causes carbon monoxide poisoning, and usually results in victims having to be given pure oxygen until they recover.
All animals with blood have hemoglobin, but the formation of the molecule varies slightly from species to species. Primarily for this reason, animal blood cannot be transfused to humans.
The presence of hemoglobin is rather easy to test for, and the amount of red blood cells in a person can be easily extrapolated from the amount of hemoglobin present in a blood test. This is as opposed to white blood cells, which have to be counted, although in modern times they are counted by a machine rather than by a technician.