The Restoration diarist John Evelyn was a man beset by curiosity. Late in life he lamented the “insatiable coveting to exhaust all that could or should be heard upon every head” that had sabotaged his “most glorious and useful undertakings”. Excess curiosity had proved the enemy of achievement. Yet Evelyn admired curiosity in others, not least his close friend and fellow diarist Samuel Pepys, “a very worthy, industrious and curious person”, as he once described him. “O Fortunate Mr Pepys!” he exclaimed in one of the scores of letters exchanged during their 40-year friendship. “Let me live among your inclinations” – which in many ways he did, sharing Pepys’s unquenchable enthusiasm for new knowledge in nature, science, the arts. Both men were avid readers and book collectors, alerting each other to works “that may happly gratifie your Curiosity”; and both were active members of the Royal Society, attending meetings where they watched with fascination as roast mutton melted into blood, and white phosphorus exploded into “divers Corruscations & actual flames of fire”, demonstrating the emergence of “light out of the Chaos”.

Yet in other ways the friends were a study in contrasts. Pepys was a tailor’s son who through wit, aristocratic connections and an eye to the main chance rose to become chief secretary of the Admiralty, in which capacity he professionalised the British navy. He was a cheerful, worldly man of large appetites, especially sexual, which made him hazardous to every vulnerable woman (tradeswomen, domestic servants, on one occasion a little girl whose mother prostituted her to him) within his reach.

Evelyn was a landed gentleman and a high Anglican of uncompromising piety. He was also a polymath who – notwithstanding his lament about failed undertakings – wrote and published on a huge range of topics, including urban pollution, forest conservation, theology, horticulture, printmaking and numismatics. Pepys, whose self-declared passions were women and music, was duly impressed: Evelyn, he told his diary, was “a most excellent person, and must be allowed a little for a little conceitedness … being a man so much above others”.

Their curious world …

Both men have been well served by biographers: Evelyn by Gillian Darley (2006) and Pepys by Claire Tomalin (2002). Margaret Willes makes no attempt to duplicate these efforts, opting instead to set the men’s relationship inside a “cabinet of curiosities”: an item of furniture designed to store and display exotic objects. Evelyn owned at least three such cabinets, one of which, a handsome ebony piece, is now in the Geffrye Museum in Hackney, east London. Willes’s engaging, lavishly illustrated book is modelled on this cabinet, moving from its exterior (politics and public life), to its exposed interior (private lives) and its inner drawers (personal passions: music and theatre in Pepys’s case – topics especially well handled by Willes; gardening in Evelyn’s; collecting books and “curious” objects for both).

By and large the device works well, replacing chronology with a closeup history of the dynamic, turbulent world of Restoration England. Evelyn was born in 1620, Pepys in 1633. Both lived through the civil war; Cromwellian republicanism; one monarch executed, another restored, a third deposed; the plague; the great fire; the Glorious Revolution – events vividly recorded in their diaries and correspondence. Pepys was present when Charles II landed at Dover to a rapturous welcome with “shouting and joy … past imagination”. The joy dwindled fast, and soon the men were confiding their disillusionment as they struggled to fulfil public duties (Pepys with the Naval board, Evelyn with the commission for sick and wounded seamen, where he worked with Pepys) impeded by the “vanity and vices of the Court”, as Evelyn complained bitterly to his friend, “which makes it a most contemptible thing”. Yet Pepys remained a Stuart loyalist to the last, paying for it with his job after the ascension of William and Mary, while Evelyn, fed up with absolute monarchs, cautiously welcomed the new political dispensation.

Both men had successful, if occasionally fractious, marriages, but when it came to sexual behaviour they were miles apart. Pepys’s uninhibited lechery has received little criticism. By contrast, Evelyn’s combination of strict propriety and clumsy gallantry has earned him ridicule (although not from Willes). Yet Evelyn would never have been found with his hand up a maidservant’s skirt, as Pepys was. Evelyn wed a woman who was clever and feisty, and he wrote admiringly about literary women, including the proto-feminist Mary Astell. When he fell in love, as some middle-aged men do, with a woman 30 years his junior, he aimed only to touch her soul, as she did his, and, while his relationship with her certainly had its peculiarities, it was underpinned by a profound respect. Is Evelyn too antique for our tastes while Pepys is a man for our times, as is often said? Sadly, in this respect at least it would seem so.

Both men were avid readers and book collectors, alerting each other to works “that may happly gratifie your Curiosity”

The young woman with whom Evelyn fell in love was Margaret Blagge, later Godolphin, a pious courtier with whom he formed a platonic “soul-union” based on mutual love of God. Willes devotes several pages to the Evelyn/Blagge relationship but gives insufficient attention to its religiosity, which means she underplays Blagge’s part in it. In fact religion could have done with more attention throughout the book, given that life and politics in Restoration England, the “curious world” of the title, were shaped by religion. This was true even of curiosity itself, which Willes treats as an uncontroversial desire for knowledge but was widely regarded at the time (including by Evelyn, in his more devout moods) as a godless vice. “Obedience is … life without Curiosity,” he wrote in a devotional text. Pursuing knowledge for its own sake was prideful (a mortal sin) and dangerous – look where it had led Adam and Eve. “Too much curiosity lost Paradise,” Evelyn’s contemporary Aphra Behn quipped. Read against the backdrop of revealed religion, the motto of the Royal Society, nullius in verba (“take nobody’s word for it”), appeared to many as impious, possibly heretical or even atheistical. Churchmen attacked the society on these grounds, forcing it to defend experimental science as compatible with scripture, a task made more difficult by the spread of Epicurean materialism and religious scepticism among members.

Pepys was a sceptic, although he didn’t advertise this. Evelyn, like many in the Royal Society, emphatically was not; yet he translated the first part of De Rerum Natura, an Epicurean poem by the Roman poet Lucretius. If ever there was a “curious” book, this was it: bold, iconoclastic, a work that many scholars regard as a founding text of modernity. Pepys owned a copy, and although Evelyn later regretted translating such an irreligious book, his earlier willingness to do so shows just what was at stake in his and Pepys’s insatiable curiosity. In earlier centuries curious men and women – knowledge-seekers, freethinkers, people who took “nobody’s word for it” – might pay for their curiosity with their lives; in some countries today they still do.

• The Curious World of Samuel Pepys and John Evelyn is published by Yale. To order a copy for £17 (RRP £20) go to bookshop.theguardian.com or call 0330 333 6846. Free UK p&p over £10, online orders only. Phone orders min p&p of £1.99.