Why running queries one by one yields correct results, but running lots of them in one chunk doesn't?
SELECT populateIfNotAlreadyIn(1, 'val1'),
       populateIfNotAlreadyIn(2, 'val2'),
       populateIfNotAlreadyIn(3, 'val3'),
       populateIfNotAlreadyIn(4, 'val4'),
       populateIfNotAlreadyIn(5, 'val5') ;


Meanwhile, you could shorten the function to just

RETURN EXISTS(SELECT * FROM t WHERE id = idArg);