Function stddev exists onfly for numeric types, and you try it with varchar:
ERROR: function stddev(character varying) does not exist
So any casting is absolutely useless because a main problem is elsewhere.
If $2 is a column name, then it is wrong in basic - you need to use a dynamic SQL
CREATE OR REPLACE FUNCTION stddev_hs_div(varchar, varchar)
RETURNS dec AS $$
DECLARE result dec;
BEGIN
EXECUTE format('SELECT stddev(%I) FROM hsggraduation .. WHERE division_name=$1', $2)
INTO dec USING $1;
RETURN dec;
END;
$$ LANGUAGE plpgsql;
You cannot to use a variable as column or table name in normal query in plpgsql ever. When you would to do it, then you have to use dynamic SQL - build a SQL string first, and execute it later.