Correct sail trim for any given point of sail, wind velocity and sail boat design is definitely an art and can take a lot of practice to get good at. A good place to start in understanding correct mainsail trim is to think of a sail as a vertical wing, which it partially is - it creates lift (which is one of the reasons modern sail boats can sail to windward) and also creates drag.
So generally, if you understand that to get the most out of boat speed you want to maximise lift and minimise drag. This basically means that you need to flatten (de-power) the mainsail the higher the wind velocity to keep the boat sailing fast BUT in control, or create a fuller profile, billow, curve (power up) in the sail in lighter conditions. How you do this, as others have mentioned, is via the mainsheet, main halyard
tension, outhaul, vang, cunningham (downhaul), traveller and leech lines. By tightening these controls you achieve a flatter mainsail; by easing them, a fuller mainsail.
Understanding this is a good place to start. Definitely get a vang fitted to your vessel and a traveller, if you don't have one. Then read some books
and go sailing and practise in your boat. Start by sailing close hauled in smoothish (sheltered) conditions in about 12 knots of wind where small changes in sail trim are instantly converted to more or less boat speed. Feel the balance in the helm
(feedback), try to find the 'sweet spot'. Watch your log when you make adjustments to see if boat speed increases (or decreases) - if it increases, take note of what you did. When you're happy with what you've achieved tacking to windward, crack off a bit and try it on a close reach, a beam reach and a broad reach.
Don't do this in strong wind (just yet) because you risk the boat being overpowered, creating weather helm
and allowing the boat to heel too much, which just confuses things...
The 2 most common mistakes
people make is to crank the main halyard too tight (someone already mentioned this) and to not reef early enough. Especially up wind, too much sail only slows the boat down and stresses the rig, creates weather
helm, more leeway and makes the helmsman's job that much harder (not to mention the mainsheet hand).
Above all else, go out and have fun
Hope this helps...