Ads don't have to be harmful for SEO, but they can be. You'll find that a lot of pages that have ads running on them rank highly for their targeted queries and brand terms. The trick is to follow best practices, and to be judicious in how you deploy those ads.
A banner or rich media ad that adheres to IAB specs should have no effect on your SEO, unless it's an ad that blocks most of the screen or blocks search engine access to your page.
You can fetch your URL with the ad running on it as Googlebot in your Google Search Console, and see what the search engine sees. If it sees a full page ad instead of your actual page, you should modify or take down that ad. You can also choose to load that ad as the last script that loads, or even defer it by some 30 seconds, so that the spider has time to crawl your page before the ad shows up.
The other thing you have to consider is how much real estate your ad is taking up on the page. Google has been viewing pages with ads that take up more than half the page, and obscuring content, very unfavorably. So you may have to limit yourself to smaller ads. On mobile, the 320px at the top of the screen is better UX than a full screen ad.
Finally, try to adhere to IAB specs and not run ads that autoplay, or are hard for the user to close.
Your other concern is site speed. Ads often slow down your site, due to all that content loading via all the containers and scripts, so you have to be judicious about how, where, and how much you load those ads.
Check out the AMP spec, which is meant to make pages faster. The AMP standard may not be for you, but the principles should give you some ideas as to the techniques you may want to try.
Run your page through Google Page Speed tool and Mobile Friendly tool. Run some diagnostics in Google Dev Tools. If the scripts are taking too long to load, you'll have to work to decrease their impact. Using Google Tag Manager can help with site speed, as it loads scripts asynchronously. Static banner ads are generally faster than rich media ads or video ads. Those Outbrain-style 8-box content containers, seeded with ads, can be a page speed nightmare.
If your page retains good UX, good site speed, and adheres to Google and IAB best practices, your SEO should be fine.