You're right, Hardly is probably the better word to use here. I don't even believe it's a proper use of nearly.
"As the year was coming to an end, hardly anyone doubted that either
William or Philippa would win the prize while the other would come in
second."
Nearly suggests "close to," or "near to." The context in which the word is being used is not typical. Saying we are "nearly there" suggests that we are very close while "hardly there" suggest barely there, or "only just slightly there." While one says we have almost arrived the other says we're not even close.
"I was nearly asleep" as opposed to "I was hardly asleep." They're quite different.
They are nearly opposite words, and hardly the same.