What causes rib pain when I breathe deeply or bend over?

Muscle pain. Deep breathing that causes pain can be muscular, a spasm or strain or pleuritic, fluid in the lung lining space. Anti inflamatories can fix both.
Rib pain. What part of the rib hurts? If it's at the front where ribs are connected to sternum via cartilage, there may be inflammation of that junction, called costochondritis. Treatment is NSAID (advil/motrin/aleve/etc) for pain & inflammation. If pain is in shaft of rib, see doc for evaluation for cracked rib, osteoporosis, or other condition affecting ribs.