It is not about whitespace, really.
That function parses from left to right. If the string starts with an integer in the given base, it returns it:
iex> Integer.parse("1")
{1, ""}
If some integer has been extracted and some character is invalid, the rest of the string is returned together with the integer so far parsed:
iex> Integer.parse("1a")
{1, "a"}
The first example is an edge case, if no such invalid character is found, the string is exhausted and you get an empty string.
Finally, if no integer is found at the start, :error is returned:
iex> Integer.parse("a")
:error
Whitespace is a particular case of this rule.