They are an attempt to scam people who do not have the digital literacy to understand what is going on. Usually they are an attempt to trick peopel into calling the number in the ad wherein a fake tech support agent will ask for a credit card number to "assist" these people with resolving the fake problem. The are harmless unless you call the number in the ad and give them you credit card number. Sometimes a script within an ad will send the browser several redirect requests to a page that will "lock" your browser. If that happens you can use task manager if you are using Windows and end-task the browser session. Or, in Linux you can kill the browser process.
Google's ad networks have an icon that will let you block or report the ad. If you want to find the URL you can find it in the browser history.
Viruses and malware can be downloaded from ad networks, or installed by clicking on the wrong thing. Several things you can do to prevent this is run Linux. The amount viruses and adware/malware targeted toward desktop linux users is very small. However, the risk of adware and malware that run in browser extensions is the same as Windows. And, you should have a administrator account and a user account for any operating system. Never use your administrator account for casual web surfing.