If, when starting out, a[i] > pivot (so i is not changed) and a[j] > pivot for all j until a[j] = pivot, the next iteration of the loop will result in a situation where j < i.
To illustrate...
Take the following array:
int a[] = [10, 7, 2, 6, 3];
On the first call of quicksort, with first being 0 and last being 4 (last index in the array), pivot will be a[2] = 2. In the first iteration if the while loop, a[0] > 2, so i is not changed. a[4] > 2, j--, a[3] > 2, j--, a[2] = 2, now we hit the if statement. 0 <= 2, so we swap a[0] and a[2] and execute i++ and j--.
Now the array looks like this:
[2, 7, 10, 6, 3]
with i = 1 and j = 1. a[i] > 2, so i is not changed. a[j] > 2, so j--, j now is 0. a[j] is not greater than 2 (since it is 2), and j stays at 0. Now, we have i = 1 and j = 0, or i > j.
If you notice, the 2 is in it's "sorted" position and does not need to be moved anymore. Also, the pivot was the smallest element in the array. Hope that helps you figure it out.