Breaking it down:
The white wires all joined together are the "neutrals". In an AC circuit, the neutral is the "undriven" side of a circuit, which does not have a voltage potential when the circuit is disconnected. You can kind of think of it as the "return path" for current, but as the current changes directions 60 times a second in the U.S., it's not quite so simple.
The bare copper wires, or sometimes green-jacketed, are your "grounds". They are a safety mechanism that provides an easier path to ground for "rogue" electrical current (frayed wires, miswiring, etc etc) than through you, or the flammable structural members of your home.
Black and red wires are "Hot" wires; these wires carry the electrical potential needed to "drive" the electrical circuit. These wires are the ones that will kill you when the power is on, even if the circuit is disconnected. Black is the "Primary" hot wire; red is usually an "auxilliary hot" to separately control two parts of a system, such as the light and fan of a ceiling fan fixture.
To properly answer your question, we need to know if you have two actual wall switches, and are just replacing one, or if you have a single module in the wall box that has two switches on it. If it's the former, then what you have (which sounds like a simple single-pole dimmer switch) is fine to replace one of the switches. If you have a combination unit that takes all these wires and has both fan and light controls, you can still make it work but you will lose control of the fan at the wall.
It sounds like you have a single unit with two switches on it, taking up a single wallbox space, and you are replacing it with a single-pole. Here are the basic steps for this:
- Turn off power to this circuit, and any other circuits that may happen to be in this wallbox, at the main breaker panel.
- Remove the wallplate but don't unscrew the switch itself yet.
- Test all the wires with a non-contact voltage tester (an absolutely essential safety tool for electrical work) to make sure all the wires are "cold". Repeat step 1 if the tester lights up.
- Unscrew and pull out the switch. Identify where each wire is currently connected, then disconnect all wires. It will be extremely helpful if the switch is marked to identify which wire is which, but it's not critical.
- Identify the "panel hot". In your situation, this should be either the wire connected to a terminal marked as "in" or "from breaker", or if the switch isn't that well-labelled, it is the black wire that does not come from the same outer insulation conduit as the red wire.
- If this is difficult to determine, separate all wires and ensure that none of them are touching anything metal, then turn the power to the circuit back on at the panel. Do not touch ANY of the wires with any part of your body and don't allow ANYONE else, especially children, to come anywhere close to the exposed wires. CAREFULLY use your non-contact voltage tester to look for the black wire that carries current. Remember or mark that wire, and cut the power at the panel again.
- Look at your new switch. There should be a terminal towards the top of the switch body, a terminal to the bottom of the switch body, and a terminal that screws into the metal chassis of the switch (which is usually anodized green, and is your ground). Connect the "panel hot" to the "bottom" switch body terminal. It USUALLY won't hurt anything if you connect it to the other switch body terminal, but DO NOT, under any circumstances, connect the black wire to the chassis terminal (the "ground"); that will at least cause you not to be able to turn the breaker back on, and at worst will "energize" the switch chassis including the metal wallplate screws; if you touch them you'll get shocked.
- Now we need to figure out which of the other two wires goes to the light, and which goes to the fan. If the old switch gave you any clues, great. If not, trial-and-error won't hurt anything.
- Pick one of these wires and screw it to the SAME terminal that you screwed the panel hot wire to. The switch will just be a convenient place to join these two wires for now; you won't have to make sure the switch is on or anything. Go turn the panel back on, and see what turns on, either the fan or the light. Turn the power back off at the panel.
- If the fan turned on, you guessed right. Leave those two wires connected to that terminal on the switch, and connect the last wire to the other switch body terminal.
- If the light turned on, disconnect the wire you chose from the switch terminal (leave the panel hot connected). Instead, connect the wire you didn't pick (which should go to the fan) to that terminal, and connect the wire you picked to the other switch body terminal.
- If this switch is in a "wet" area (within 6 feet of a sink, tub, shower, or anywhere you could possibly imagine standing water such as your basement), you are required by code to connect a ground wire to the switch. If this is the case, or you just want to be ABSOLUTELY sure, then head to your hardware store and pick up two additional items; a length of 14AWG bare copper wire (you can also just buy a length of 2-conductor Romex wire and remove the copper element from it), and some wire nuts of the appropriate size for 14AWG wire. They make special "grounding" wire nuts that are green with a hole in the top, that create a "Y-junction" joining several wires to one wire that then connects to a device chassis. These can be useful but shouldn't be necessary. Screw the wire into the grounding terminal, cut to some appropriate length, and twist the other end around the grounding "bundle". Use the wire nut to ensure it stays put.
- Wrap the entire switch body with a layer or two of electrical tape, being sure to cover all the electrical terminals on the switch. This is an extra level of insurance to prevent short-circuiting when you put everything back together.
- After making sure there are no bare wires showing other than the ground wires, and being careful not to pinch any wires, put the switch back in the wallbox.
- Turn the power back on at the panel. The fan should start up; it is now effectively "hard-wired" into the circuit, and you will need to use the pull-string to control it. The switch should control the light; on/off/dim should all work normally. Make sure that the dimmer does not also affect the fan; if it does, turn the panel off, go back to step 7 and swap the wire you identified as going to the fan to the other terminal; it somehow ended up on the opposite side of the switch as the panel hot and is being controlled by the switch.
- Once everything's working to your satisfaction, put the wallplate back on and enjoy.