When you open an ear of corn and some (or most) of the kernels are missing, that means the corn was not pollinated properly. To ensure pollination plant corn in a block, not rows.
Corn is wind pollinated. The male flower is the tassel; it forms at the top of the cornstalk and produces pollen. The female flower is the silk; silks are fine strands that emerge from the husks that cover each ear of corn lower on the plant. Every potential corn kernel is connected to a silk.
Pollen must drop or be blown from the tassels onto the silks for plump kernels to develop. When there are gaps in an ear of corn, that means a silk or silks were not pollinated.
Corn pollination is more apt to happen in a home garden when corn is planted in blocks of four to six short rows instead of one or two long, single file rows.
To increase successful corn pollination, plant corn in a patch at least four feet by four feet. Space plants six to eight inches apart, in rows about 18 to 24 inches apart. When the plants grow tall and form tassels and silks, a gentle breeze (or a rustle of your hands) will ensure pollen falls from tassels to silks (and not to the ground).
An alternative to planting corn in short rows is to plant corn in hills set in block or square formation. Plant three or four stalk per hill and set hills about three feet apart.
To give Mother Nature a hand, you can hand-pollinate the silks. When silks emerge from ears of corn, head out to the corn patch and shake the tassel on each stalk on a daily basis for several days. This will ensure that pollen drops from the tassels to the silks below.
For successive harvests throughout the growing season, sow new blocks of corn plants every two weeks. Planting two weeks apart is particularly important if you are growing more than one variety of corn.
Corn plants easily cross-pollinate and cross pollination of differing varieties can result in corn that is less tasty. By planting differing varieties two weeks apart, the tassel formation of the second variety will not occur at the time the first is in silk.
More tips at How to Grow Corn.