Writing a spec script for an existing TV show is the first step for writers wanting to break into TV.  It's how I got an agent and my first staff job (on The Cosby Show) when I began my career – I wrote a spec Cheers.  Entire books have been written on the subject of writing for TV, but for a quick primer on the absolute essentials, check out my article in the ezine writeononline:

http://writeononline.com/2010/05/20/moving-write-along-advice-from-the-experts-writing-a-tv-spec/

And for a more complete education on writing for TV, come be a Television major at Chapman University!