A more explicit version of Qiaochu's answer : $S_n$ can be viewed as a Coxeter
group of type $A_{n-1}$. The maximal length is $\frac{n(n-1)}{2}$, achieved by
the element $$s_1(s_2s_1)(s_3s_2s_1) \ldots (s_{n-1}s_{n-2} \ldots s_2s_1)$$.

This is a classical result in Coxeter groups theory. Sketch of the proof : for each
$i \in [1,n-1]$ let $G_i$ be the so-called parabolic subgroup generated by
$T_i=\lbrace s_1,s_2, \ldots ,s_n \rbrace $. For any $w\in G_k (1 \leq k \leq n-1)$ we can write $w=w_1w_2w_3 \ldots w_r$ where each $w_i \in T_k$ and $r$ is minimal.
Among all those decompositions, we choose the one with as many
generators in $T_{k-1}$ on the left as possible. This shows that
$w$ can be written $w=w'x$, with $w'\in G_{k-1}$, and $x\in X_k$
where $X_k$ consists of the element $x\in G_k$ all of whose
minimal decompositions start with $s_k$.

It is not hard to show that the pair $(w',x)$ is unique (this is because
$G_{k-1}$ and $X_k$ are disjoint) and trivially we have $l(w)=l(w')+l(x)$.
By induction, any $w\in S_n$ can be written uniquely $w=x_1x_2 \ldots x_n$,
where each $x_i$ is in $X_i$, and furthermore $l(w)=l(x_1)+l(x_2)+ \ldots +l(x_n)$.

Now, when the group is $S_n$ it is a straightforward exercise
to show that $$X_k=\lbrace s_{k},s_{k}s_{k-1}, \ldots, s_{k}s_{k-1} \ldots s_{2}s_{1}
\rbrace$$ for any $k$. Therefore $X_k$ has a unique element of
maximal length, $\xi_k=s_{k}s_{k-1} \ldots s_{2}s_{1}$, and we deduce that $S_n$
has a unique element of maximal length which is the product
$\xi_1\xi_2 \ldots \xi_{n-1}$.