Changing old light switch 2 black wires and 1 red
This appears to be a conventional switch configuration. The white wire carries the neutral on to the outlet that is switched. One of the black wires is the hot. The other is an extension of the hot to some other fixture or to one half of the switched outlet. The red is the switched hot.

After removing the old switch, the preferred method is to join the two existing black wires together and to add a short additional black wire (called a pigtail). Cap it with a wirenut or use push-in connectors to attach all three wires. The other end of the pigtail goes in one side of the new switch and the red in the other.