An ordinary (not "smart") switch has two or three connections:
- Incoming Hot, a.k.a., Hot or Line
- Switched Hot, a.k.a., Load
- Optionally, ground
FYI, ground is optional because if a switch is installed in a properly grounded metal box then it gets ground through the yoke and does not need a ground wire.
Your existing switch appears to have Hot in the bottom (because that wire is connected to a couple of other wires, one bringing in power and the other going to another switch) and Switched Hot at the top. Note that on an ordinary switch, top and bottom are irrelevant with respect to Hot vs. Switched Hot.
Smart switches, dimmers, etc. have a lot of different possible configurations, depending on how they are designed, how they get power (if they need constant power), how they handle 3-way switches, and sometimes other things.
In this particular case the key issue is that the blue wire is used for 3-way switching (two switches that control one light). Since you are not using 3-way switches, you ignore (cap for safety) the blue wire. The other wires are straightforward:
- Black to Hot black
- Red to Switched Hot black
- Green to bare ground
Note that this particular switch does not care about Hot vs. Switched Hot. Many do care, many don't. Always read the directions to be sure. But by convention (not required by code), red is for Switched Hot instead of Hot, so I would connect it that way even though your Switched Hot wire is black (because that's the way cables work).