First of all, myopia, or nearsightedness, means that relatively speaking, you see things better up close than far away. This is easy to remember, because the term "nearsightedness" suggests that you are best "sighted" at "near."
Take a look at the drawing here, of a myopic eye. Ideally, the cornea and lens at the front of the eye (left side of the drawing) should focus the light rays, from the image the eye is trying to see, right on the retina, at the back of the eye (right side). But look at this eye -- the image is focused in front of the retina. Nearsightedness! The eye is either too strong in its focusing ability or too long for its focal power.
So how can this be corrected? One way is by moving the object you look at closer to your eye. Why does this work? Simple optics. As the distance from the object to your eye decreases, the distance from the front of the eye to the image created by the eye increases -- the focal plane "moves backward." This means that instead of being focused in front of the retina, the image will be in focus farther back -- ideally, right on the retina. The more nearsighted you are, the closer this distance between the object you are looking at and your eye will need to be for you to see best.
OK, Dr. Weed, holding things close might work for books and whatnot, but it's not so great for sporting events, oncoming cars, other humans, etc. How else can nearsightedness be corrected? There are a variety of medical and surgical options. By wearing corrective lenses -- eyeglasses or contact lenses -- that "push the image back," so to speak, the eye can then focus images on its retina. Alternatively, a variety of surgical options, most commonly laser vision correction (e.g. LASIK), can be pursued.