The Keystone Effect (also known as the Tombstone Effect or Keystone Distortion) occurs because objects closer to the camera look bigger than objects that are further away. 

For example, in the diagram below a group of people are arranged in the shape of a square. In this image the camera is looked straight down from above the centre of the group:

Now move the camera so that it is looking down at an angle from in front of the group:

Camera position in relation to the group

 From this camera position the group would look like this:

The group no longer appears square because the people at the back look smaller than the people at the front, because they are further from the camera. This is the keystone effect and is so named because the tapered trapezoid shape resembles an architectural keystone.

If you want the group to look square in the camera you need to put more people at the back and fewer at the front, as shown below:

In this example there are twelve (12) people in the back row and eight (8) in the front row. When viewed from the camera this group will look square...

How much bigger the back row needs to be compared to the front, and how deep the group needs to be varies depending on the lens focal length and how much the camera is tilted down from horizontal. 

The GroupCalc Keystone Calculator does this calculation for you. It can also do these calculations for more complex shapes (see Shape to be Drawn)