The dimmer is a 3-way switch and you need a 3-way switch to replace it.
One of the terminals on the dimmer should be marked COMMON or COM. One of the terminals on the replacement switch will be similarly marked. Place the wire that was on the old common terminal on the new common terminal.
The other two black or red wires go to the other terminals on the new switch, called travelers. They may or may not be marked, but it does not matter which wire goes on which, so long as the common is right.
Often the common terminal screw is a different color than the travelers, but not always so.
The green wire goes on the ground screw on the new switch.