For many it is an incredibly stressful experience to give a speech, but there's plenty you can do to prepare yourself well. A well prepared speech is usually much better and a much less stressful history for the one giving it.
Depending on the event, there are lots of different unwritten rules about what you may / may not say, how long it should be, etc. etc. Most of the rules you can ignore, but there are a couple things you should not bring up in any speech;
Ex girlfriends or boyfriends
Bringing up an old girl- or boyfriend in a wedding party speech is not really a good idea. At best it is boring; at worst it may offend the wedding party couple. A good rule of thumb is to never bring up old partners if the new wife or husband is present, that way you won't offend anyone.
Critique
Criticism should always be delivered with an obvious touch of humor to it. If there is anything in particular you have argued over, you should of course take it up at a later time - not when you are giving a speech. Even though you may find the mentioning of the argument funny, the one you are giving the speech to may feel differently about the situation. Best is to avoid criticism in any shape or form.
Secrets
Secrets are a common theme when people give speeches, especially at wedding parties. Although a popular theme, there is always the risk that you have misinterpreted the size of secret and, instead of being funny and personal you make a total fool of yourself. There are of course secrets of such nature pretty much no one would be offended by them. A secret from early childhood is a good example of this; they tend to be innocent enough.
There are of course many other things you should avoid when you want to make speeches, but one gets far with a little common sense.
For those of a very lazy nature, or those who just can't express themselves in public, there are pre-written speeches you can buy online. Although this may sound foolproof, but if anyone have heard the speech before it can turn ugly real fast.
Should you write your own speech, it is a good idea to practice to speak to someone else, to rehearse and get some feedback. Is it funny where it is intended? Too long or too short?
Before writing the speech it's usually a good idea to think of a good theme for it, and perhaps set a timeframe. At many wedding parties there are numerous of speeches, short speakers are often much appreciated. If you, on the other hand, are one of few speakers you can extend your time limit a bit, but don't overdo it.