Brace subtitutions are performed before any other, so you need to use eval or
a third-party tool like seq.
Example for eval:
for i in `eval echo {0..$length}`; do echo $i; done
This information can actually be found in man bash:
A sequence expression takes the form {x..y[..incr]}, where x and y are either
integers or single characters, and incr, an optional increment, is an integer.
[...]
Brace expansion is performed before any other expansions, and any characters special
to other expansions are preserved in the result. It is strictly textual.
Bash does not apply any syntactic interpretation to the context of the expansion
or the text between the braces.