I want to give my players a bag of devouring, but I am worried about them using it to just eat all of their enemies. How can I prevent them from doing this and is there a certain level they should reach before I give it to them? (I am thinking at a certain level most monsters/baddies would be able to break out)
This bag superficially resembles a bag of holding...
Which means the opening is likely that of the Bag of Holding:
roughly 2 feet in diameter at the mouth
So the players would have to wrestle the creature's arm, leg or head into the opening of about 2 feet, which would likely take something like a grapple first. So, 1 action to grapple, 1 action to attempt to stuff a limb into the bag, which would be another roll. As DM, I'd do it as a contested Strength (Athletics) roll against the creatures Dexterity (Acrobatics) or Strength (Athletics)).
Then the creature would have to do the percent roll and 50%. If the creature succeeds there is a chance the creature could pull out something the players fed to the bag earlier, which could work out worse for the players.
50 percent chance that the creature is pulled inside the bag.
creature can use its action to reach into the bag to pull a creature out, doing so with a successful DC 20 Strength check (provided it isn't pulled inside the bag first)
The creature, if it fails, could likely return a turn or two after it is pulled in with the DC
A creature inside the bag can use its action to try to escape with a successful DC 15 Strength check...
Also remember that "boss" monsters have legendary resistance, so they won't stay inside the bag. Large enough creatures won't fit through the dimensional portal. Some creatures can't be grappled. And it isn't likely they are going to be able to shove a Dragon or Strahd into the bag.
You can’t attack with a bag of devouring
It doesn’t say it can, so it can’t. Nor is there any way in the rules to put any part of an active creature into the bag unless that creature permits it.
The bag is really handy for cleaning up after the battle but it’s not much good during.