Your language correspond to the famous dangling else problem and it is well known that no $LL(k)$ grammar is able to parse it. The reason is that a $LL(k)$ grammar should be able to decide if a $a$ is paired with a $b$ when the $a$ is seen and the next $k$ symbols may be $a$.
Note that to make it $LR(1)$ you can't use a grammar like
S &\to aSb \\
&\to aS \\
which is ambiguous. You have to use to
S &\to aS \\
&\to R \\
R &\to aRb \\
But some parser generators like yacc are able to cope with that ambiguity, but the input has to be correctly ordered for them to work. Similarly, if you left factorize the first grammar, you get Raphael's grammar
S &\to aST \mid \varepsilon \\
T &\to b \mid \varepsilon
which has an ambiguity which doesn't prevent to generate tables for LL(1) parsers.