This term for a person who is a fool or a simpleton has for the most part vanished except in works that consciously seek to evoke a bygone age through antique language.
The most likely place to encounter it is in Volume Three of J R R Tolkien’s The Lord of the Rings: “You’re nowt but a ninnyhammer, Sam Gamgee: that’s what the Gaffer said to me often enough, it being a word of his.” At one time, it was an excellent addition to one’s armoury of invective, as here in John Arbuthnot’s satirical pamphlet of 1712, The Law is a Bottomless Pit: “Have you no more manners than to rail at Hocus, that has saved that clod-pated, numskull’d ninnyhammer of yours from ruin, and all his family?”
Ninnyhammer is first recorded from the late sixteenth century. Its origin isn’t altogether clear. The first part, ninny, looks like the word we still know today, which is thought to come from a shortened and modified version of an innocent, because innocent at this time could mean a person lacking in intelligence or sense, who was silly, half-witted, or imbecilic. However, it’s far from certain from the dates when they were first used whether ninny comes from ninnyhammer or the other way around. The second part is less obvious, but might be from hammer-headed, which could also then refer to a person who was dull-witted or stupid.