There are two separate concerns here: (1) why the keys were shifted originally, and (2) why they remain shifted nowadays.

The computer keyboard as we know it today came from mechanical typewriters, because at the time the first computers were developed many people were already trained in typing on those machines, so using the old design helped with marketing and eliminated the need to retrain. At the time computers came to be, typewriters already existed for over 100 years, and they underwent a significant evolution in that time. One thing however remained relatively constant within that evolution: the placement of keys on the keyboard. This "QWERTY" keyboard can be traced to the Sholes and Glidden typewriter designed around 1868. (Other typewriters with different designs existed before, but it is the Sholes and Glidden one which became commercially successful.) The notes from the inventors indicate that they designed their keyboard after the piano keyboard (in fact, originally there were two rows of keys only).

Now, what about the reasons for keeping the keyboard the way it was? Most likely this is because such design is somewhat more ergonomical:

When the rows are shifted one relative to another, each key in the middle has 6 equidistant neighbors. This means a finger can easily jump from one key to other six. With the rectangular grid, each key would have had only 4 direct neighbors, whereas other 4 neighbors would be roughly 1.4 times further away. In a 10-finger typing method the fingers almost never have to travel more than one key away from their "home" location, which means the triangular grid is more ergonomic.

On the other hand, we see that on mobile devices and tablets the "virtual keyboard" uses a rectangular grid (well, at least on those devices that I own). This is because nobody uses a 10-finger typing method on a smartphone, and hence rectangular keyboard becomes slightly more preferred.