Ideally you'd use each for their intended purpose, but in a pinch each can be used to complete the others function. Let's take a closer look at what makes these tools work.
What is a drill?
A drill is tool used to drill holes. The motor is directly connected to the drill bit, which allows the bit to spin at high speeds. This allows for faster drilling.
The torque curve, and motor speed of a drill have been optimized for rapid material removal. A good drill will drill a hole faster and more accurate than any other tool. The drill bits used in a drill have evolved to be the most cost effective way of drilling a hole.
What is an impact driver?
An impact driver is a tool used to drive screws and bolts. It uses an impact mechanism in-between the motor and the bit to generate more torque than a drill can provide.
The gearing, motor speed, and torque curve have all been optimized for driving screws. An impact driver allows the user to drive screws with the least amount of effort and error.
An impact driver can produce high torque at very low rpm (less than 50rpm). This is essential to unseat stuck screws.
Which one is the better tool?
The immediate answer is that the two tools do different things: the drill makes holes, and the impact driver drivers screws. Both, however, can be used to complete the others function.
Driving screws with a drill
A drill can be used to drive screws. Oftentimes it will seat a screw without problems. At other times a screw might not go in no matter how hard you try.
The problem comes from the torque profile of a typical drill. At low speeds a drill has little torque. It might be impossible to drive a stuck screw all the way in. The drill would have to spin at 300 rpm to produce enough torque to move the screw. Getting the drill from 0 to 300 rpm without slipping of the screwhead is the hard part.
Drilling holes with an impact driver
A impact driver can be used to drill holes. It does so almost as well as a drill, primarily because impact drivers spin at a lower speed compared to drills. The problem comes when purchasing bits. Impact drivers have hex chucks, which required hex shank drill bits. These bits are 5x to 10x more expensive than standard drill bits, which a drill uses. Over the long run, drilling holes with an impact driver will be an expensive endeavor.
If I only want to buy one tool, which one should it be?
An impact driver is the better tool to have around the house. Driving and loosening screws is a more common task than drilling holes. If you need to drill a hole, you'll have to pay more for the bit. In a residential setting, however, your bits will last a long time. Get a drill when you need to drill a lot of holes.
A drill is a different tool than an impact driver. Use a drill to drill holes, and an impact driver to drive screws. Both can be used in place of the other, but they'll perform badly. If you only want to buy a single tool, make it an impact driver.