Understanding `null` with Oracle Function's IF-Statement
If you pass any number except the number 1 then your select returns no data and raises a no_data_found exception.  Not sure what you are wanting to do but a simple solution would be to add an exception.

create or replace FUNCTION nullFunction(a NUMBER) RETURN NUMBER IS
varX NUMBER;
BEGIN
select 1 into varX from dual where exists(select 1 from dual where a = 1);
 RETURN 1;
EXCEPTION
WHEN no_data_found THEN
RETURN 0;

END;


Alternatively restructure the select from dual so that it cannot return a no_data_found.