I assume you mean why would someone put a bunch of links and messages all over it? Who knows really, most likely to get a few spam sales, or up a malicious websites search engine rankings but from the code on your site (chose not to be public), it looked like they wanted to build a link farm to their pharmaceutical junk, products and so on.
The code in the hack indicates they simply wanted to spam every link on your site and pages with the type of links you get in spam e-mail. I’ve seen this spreading from time to time amongst WordPress website that are outdated. Sometime the infection is sneaky and not found until days later as it infects posts that a week or more older.
Websites, just like computers and e-mail accounts these days need to be scanned for malware lurking in the code, and for any forceful entries into the backend systems for maintenance and editing.
Since a majority of websites are now “running” software, just like your computer does, there are systems that when accessed allow users to easily change almost everything about a site.
Your best defense is to back up your site often and keep the software your website is running (WordPress in this case) up to date. Let me know if you have trouble, I’m glad to help!