If you want to catch the conversion problems, then consider TRY_CAST or TRY_CONVERT. In addition, fix some defects of initial approach:
CREATE FUNCTION [dbo].[fStringToDate]
(@pString varchar(8))
RETURNS date
AS
BEGIN
declare @return date
declare @s as varchar(max) = TRIM(@pString)
set @s =
case LEN(@s)
when 8 then
SUBSTRING(@s, 5, 2) + '/' + RIGHT(@s, 2) + '/' + LEFT(@s, 4)
when 6 then
RIGHT(@s, 2) + '/01/' + LEFT(@s, 4)
when 4 then
'01/01/' + @s
end
set @return = TRY_CAST(@s as date)
return @return
END