As a noun, the phrase is best written as shown in the title (They lost by a hair’s breadth); as an adjective, the phrase is best hyphenated (Theirs was a hair’s-breadth loss). The idiom refers to the width of a single follicle of hair and should not be written as hair’s breath, which makes no literal or idiomatic sense.