Google’s John Mueller said that it can be risky to buy old domains. He said that you can clean up old domains if they have been used by spammers. However, it can take a lot of time.
In short, you can clean it up, but it's impossible to know ahead of time how much work / time it will take. Content issues tend to be easier, issues with links might be more involved. I suspect you have the know-how & tools to take something like that on though ?— ? John ? (@JohnMu) October 16, 2019
John Mueller compared buying old domains to buying used cars:
There's not really much to prove, since you can't guarantee what a site would rank as :). It's like buying a used car; sometimes it's easy to get things working well, sometimes it takes a really long time & a lot of work and you still have hard-to-find noises.— ? John ? (@JohnMu) October 16, 2019
How to check if an old domain has many spam links
You can use the Link Profiler tool in SEOprofiler to check if a domain has many spam links. Just enter the domain name in the search form of the Link Profiler tool and you will get the results immediately: