How long does screw have to be to anchor bookcase?
A really robust answer to this requires some idea as to whether the IKEA bookshelf is sitting on the floor or if it is meant to hang up on the wall with no support from the floor. For the case that you are proposing that there would be no floor support I would strongly suggest that you abandon that idea and stay with the unit sitting on the floor. This style of unit really needs good solid support under the vertical side panels. 

You do not want to secure the BILLY bookcase by screwing through backer material into the wall. The back of these units is basically a paper board material that slides into some side grooves and gets a couple of nails at the bottom. It will not be a secure anchor point.



To prevent tipping from the wall you need to use the supplied bracket or a similar separately purchased item. It would look something like this:



The installation directions will show how to install the brackets in a way that they are attached to the wall using a user supplied screws. The screw should be a #8 or #10 size screw and penetrate the wall stud at least 1" to 1.5". Make sure to accommodate the thickness of the wall covering such as 1/2" drywall when selecting the screw length.