Slugs generally are shaped like bullets, have much larger bearing surface (contact area with barrel), and require a decent amount of power to use. And a cooperative barrel.
Pellets shoot well in most all barrels. Though some pellet desigbs/profiles don't fare well at high speeds (or any speed, lol). Pellets have a very minimal bearing surface, and have a very thin skirt that seals air pressure behind the projectile, and also is used to drag stabilize. Pellets also lose velocity much faster due to this, and have poorer trajectory/energy retention at range. (sometimes this is a desirable trait)