Trying to replace and make a 3-way dimmer switch work
The good news -- you can do this.

Contrary to my previous version of the answer (which mixed up which switch was paired with which dimmer), the 3 wire cable between the RH dimmer in the top image and the LH switch in the bottom picture means that you can do this without pulling wire.  Take the black from the 2 wire cable and connect it to the black screw on the dimmer.  Then connect the red and capped off black from the 3 wire cable to the brass screws on the dimmer, and your 3 way switch should work properly.  If it doesn't, post another question linked to this one with a photo of the light box.