The hole has no purpose. The "hole" is the pin that holds the firing pin in the hammer. Some pins are solid, while others are hollow, thus showing a "hole." It is not just Cobras that have this variation.
The visible hole in the hammer pin on Colts was used approximately from 1966-1968 but I have seen at least one 1970 D frame that also had that pattern hammer. After approximately 1968 Colt went back to using the solid pin that was always used for Colt DA hammers. I believe the hollow pin is a spring or roll pin. The solid pins are just that, solid.
S&Ws always use a hammer pin with a visible hole. Colt's didn't except for the above mentioned era guns.