Because do is only optional to while that if you place it on a different line, it's already read as part of a different context:
while conditional [do]
   code
end
Here, the while statement is still valid and do no longer connects to any that's why you see the error.
while conditional  ## Parser validates this as complete.
   do              ## Parser sees this keyword as lost.
   code
end
It's as if you did it without the while block:
do    ## Lost.
code
Which also produces the error syntax error, unexpected keyword_do_block.
To clarify things more a bit, the while syntax is not multi-line when trying to recognize the following do. This may work:
while conditional do
   code
end
And this one as well:
while conditional \
do
   code
end
But the form in question wouldn't.