First, from the Safari menu bar, select
Safari ▹ Preferences... ▹ Remove history items: Manually
Triple-click anywhere in the line below on this page to select it, then copy it to the Clipboard by pressing the key combination command-C:
~/Library/Safari
Quit Safari.
Select
Go ▹ Go to Folder
from the Finder menu bar. Paste into the text box that opens by pressing command-V, then press return.
A folder window should open. Inside that folder, there should be a file named
History.db (OS X 10.10 or later)
or
History.plist (OS X 10.9.5 or earlier)
Move that file to the Desktop.
Restore the file with that name from a backup that predates the changes. If you back up with Time Machine, enter it and scroll back to a snapshot of the open folder.
When you relaunch Safari, the old history should appear. When you're done with it, you can revert the change by replacing the history file with the one you moved to the Desktop. Otherwise, delete that file.
Revert the change in Safari's preferences to whatever you want it to be. If you leave it on Manually, the history file will grow without limit and may eventually slow down the browser.