I noticed that most of ICs (DIP or SOP) have VCC and GND pins on diagonally opposite pins. Decoupling capacitors must be connected with shortest traces. Placing power pins in the corners makes the traces (inside the chip and outside on PCB) longest possible. It doesn't make sense to me, what's the purpose of doing it this way?
I believe the answer to your question is historical rather than logical.
I am old enough to remember when even double sided circuit boards were new.
Before this, using a DIP packaged IC (which was what there was then) on a circuit board was made easier by having VCC and GND on opposite ends of the package. This meant that the power to supply the device could come from the top and bottom 'rail' on the PCB and still leave the logic circuits some space to route to each other with the minimum of bridges. Decoupling capacitors were generally placed beside logic chips, with the legs of the capacitor left long to ensure minimal hole-drilling.
Remember then that there were no CAD packages to help design your layout and test it either. It was all done on paper, or in my case because I was lazy, usually a masking pen directly on the board with some meths for stuff-ups. You could also use the meths for cleaning the circuit board ;-)
I agree with robert. It made routing of power easy in early boards. Such as this one:
You can clearly see the power and ground rails above and below the chips. And the decoupling caps can just use the ground of the row above to keep the distance short. Nice and simple to route. It is so much harder these days with all the seemingly random placement of power and ground pins on chips.
Decoupling capacitors are meant to reduce variations in voltage on the power line caused by changes in current draw, as well as reduce high frequency noise introduced elsewhere in the system. Just because the GND pins are far away on the IC, does not mean that your decoupling caps need to go between those pins - place them close to the VCC pin, and route a GND line close by (or place vias to a GND plane).
The reason VCC and GND pins may be far away, as @PlasmaHH put it, is because it makes sense for certain ICs due to the die layout. Consider a circuit: power -> a bunch of stuff -> GND; it makes sense to have those pins be far away to accommodate for internal circuitry. Additionally, it may reduce the amount of capacitance created (externally and internally) between those two pins.
Nearly all modern PCB's have at least one ground plane. In other words, unoccupied space on both sides of the PCB is filled in with a big "ground wire".
When the engineer lays out the PCB, he places each decoupling cap as close as possible to its VCC pin. He connects one of the capacitor's pads to the VCC pin with a short trace. He connects the other pad to a via into the GND plane.
Because the ground plane is so wide, its impedance is very low. With a very short trace between the VCC pin and the cap, the inductive parasitic of the wire is minimized.
Having VDD and VSS pins separated by a significant distance can only be afforded in not so critical applications. In such cases it could be more important to match established pin layouts instead of using the optimal placement.
An integrated circuit circuit is enclosed by the so called pad-ring. I took an arbitrary image from Google to show this:
Among the yellow traces that can be seen in the corners are the supply lines. They run around the whole chip because they are needed for the ESD protection circuitry and to supply digital I/O pads. It should be clear from this that the ring could be supplied from any two pads in the ring (assuming there aren't multiple supplies).
From the IC designer's point of view critical signal lines and supply pads are placed in a way to minimize the inductance of the bondwires and the leadframe. In particular VDD and VSS would be placed close together and sometimes even with double-bonding to reduce parasitics.
So for an optimum placement VDD and VSS would not be placed on opposite corners.