Why I am getting Parse error: syntax error when I use ‘wp_is_mobile’?

You should not be executing anything before your DOCTYPE tag. That will all be invalid code and is also the issue leading to your error.

In general, any output like above should be done after the <head></head> tags, although some prefer to hook into the wp_head hook to execute functions like your code. I do prefer however to move such code after the closing head tag.

So your solution would be to move your conditional code to just after the closing head tag