Being asked to give a speech at a wedding is one part complete honour, one part total curse. You obsess over how to be funny. Put off writing it as much as possible. Talk it up outrageously to the bride and groom.
2. Don't over-complicate it. A wedding speech needs to have: a) a sentimental section showing your closeness with the bride or groom, b) a touching way of wishing the couple well and c) at least one toast. For a) reference a story showing the happy couple in the best possible light and for b) don't worry if you're not entirely comfortable spouting schmaltz. Borrow a quote from a film the couple love or a person of note - believe it or not, Albert Einstein came out with some super wedding appropriate crackers.
3. Remember it's not your job to shock. So, the bride has had a zillion boyfriends. So, the groom thinks his life is an extended version of Jackass. Those things are for jokey chats later after too much free wine - airing a couple's dirty laundry on their wedding day is the ultimate dick move. Your speech should be entertaining enough to hold guests' attention but reserved enough that you can still look the bride and groom's parents in the eye.
4. It doesn't have to be super long. Don't tell yourself you've got to fill 10 minutes - write what comes naturally and finish at a point that makes sense. One minute of charm is better than five of zzzzzzzzs....
5. It's okay if it's not hilarious. Heartfelt stories and sentiment are a million times better and more memorable than crap jokes. Be honest with yourself on this point - if you wouldn't laugh at something you've written obviously intended to be a funny, the chances are others won't either. And no one wants uncomfortable pity titters.