While spam can contain links leading to unsafe sites, websites also include connections which can cause problems. Most legitimate and high traffic sites are usually safe, although there have been cases of them being compromised, or temporarily running clickable ads which turn out to be unsafe. Malware links are more common on sketchier sites, such as those involving pornography or pirated downloads.
Internet browsers like Chrome, Edge, Firefox, and others are very sophisticated programs, and can virtually act like an operating system themselves. They can run other apps, administer databases, and perform many other things which day to day computing involves. Running cloud applications like Google Docs or Slack are examples of leveraging this power.
That power creates danger. Any lapses in security by the app itself can allow malware to infect user systems and direct the computer to undertake actions which are not safe. Even if the browser is secure, though, they are literally designed to allow things which, while useful and powerful, can lead to problems. As much as it is convenient to click a link and load software, there is little to prevent a criminal from substituting malware which secretly compromises a system.