I think you have to keep in mind that Hogwarts is a pretty dangerous place, generally. As Hagrid put it:
'I mean, it's always bin a bit of a risk sendin' a kid ter Hogwarts, hasn' it? Yer expect accidents, don' yeh, with hundreds of under-age wizards all locked up tergether,'
Harry Potter and the Half-Blood Prince - p.379 - Bloomsbury - chapter 19, Elf Tails
The Forbidden Forest is a dangerous place, but then Charms class is hardly a soft play area, is it?
As well as that, I think the quote that you provide in your question is very telling:
'First-years should note that the forest in the grounds is forbidden to all pupils. And a few of our older students would do well to remember that as well.'
Dumbledore's twinkling eyes flashed in the direction of the Weasley twins.
Harry Potter and the Philosopher's Stone - p.94 - Bloomsbury - chapter 7, The Sorting Hat
He doesn't seem too stern, or grave, does he? Indeed, it seems he has his strong suspicions that the Weasley twins have been in there; but he doesn't ever seem to pursue his suspicions. Personally, I've always been left with the feeling that, if anything, Dumbledore was faintly amused by their antics - although that's just a personal impression.
Now, don't mistake me. The Forbidden Forest is forbidden and is very dangerous. Students aren't allowed in there unsupervised, according to school rules, and with good reason. It is much more dangerous than, say, Charms class. However, I really can't see Dumbledore objecting to the students going in under Hagrid's supervision. That certainly doesn't seem out of character for Dumbledore, nor does it seem in violation of the spirit, or the letter, of the school rule about the Forbidden Forest. (Although whether the group splitting up was such a good idea, is another matter). The point is, though, that students aren't allowed in there unsupervised, as Vishvesh explains in detail in their fine answer.
To further underline this point, recall that Hagrid takes an entire party into the Forest in The Order of the Phoenix (chapter 21, The Eye of the Snake). Now, Dolores Umbridge may not have been very impressed with his lesson - but she actually seems to have objected to the Thestrals, more than the location of the class - and she was looking for reasons to sack Hagrid. There's nothing, though, to suggest that Dumbledore minded about this supervised foray into the Forest, and it certainly doesn't look like he tried to stop it (because Hagrid would listen to Dumbledore).
Finally, I would draw your attention to the fact that, at Hogwarts, detentions can consist of all sorts of unpleasant things. Even though hanging by your wrists from the ceiling has been discontinued, detentions at Hogwarts can be a wee bit draconian. It seems that occasionally students can be made to do things that they normally wouldn't for their own safety. For example, in The Half-Blood Prince, Snape makes Harry sort out flobberworms without protective gloves:
'Harry?' said the new Chaser, Demelza Robins, appearing suddenly at his shoulder. 'I've got a message for you.'
'From Professor Slughorn?' asked Harry, sitting up hopefully.
'No ... from Professor Snape,' said Demelza. Harry's heart sank. 'He says you're to come to his office at half past eight tonight to do your detention - er - no matter how many party invitations you've received. And he wanted you to know you'll be sorting out rotten Flobberworms from good ones, to use in Potions, and - and he says there's no need to bring protective gloves.'
Harry Potter and the Half-Blood Prince - p.222 - Bloomsbury - chapter 11, Hermione's Helping Hand
The Detentions are also, often, supposed to do some good or serve some purpose as Hagrid remarks in that very scene:
'But this is servant stuff, it's not for students to do. I thought we'd be writing lines or something. If my father knew I was doing this, he'd -'
'- tell yer that's how it is at Hogwarts,' Hagrid growled. 'Writin' lines! What good's that ter anyone? Yeh'll do summat useful or yeh'll get out. If yeh think yer father'd rather you were expelled, then get back off ter the castle an' pack. Go on!'
Harry Potter and the Philosopher's Stone - p.182 - Bloomsbury - chapter 15, The Forbidden Forest
Hagrid needed an important job doing, I doubt very much Dumbledore would've objected to him using the students that had been placed in detention. In fact, I'll go a bit further. Remember Harry's observation at the end of the book:
'He's a funny man, Dumbledore. I think he sort of wanted to give me a chance. I think he knows more or less everything that goes on here, you know. I reckon he had a pretty good idea we were going to try, and instead of stopping us, he just taught us enough to help. I don't think it was an accident he let me find out how the Mirror worked. It's almost like he thought I had the right to face Voldemort if I could ...'
Harry Potter and the Philosopher's Stone - p.219 - Bloomsbury - chapter 17, The Man with Two Faces
I'd be very surprised if Dumbledore hadn't heard about the attacks on the unicorn and I bet he had a good idea who was behind them. I wouldn't be at all surprised if he was actually very happy that Harry was going to be going into that Forest to help get to the bottom of it. It may even have been his idea, you never know.