So tough to diagnose....especially when the temp gauge used to read accurately (assuming it did!)...it would have to be a wiring,ground or dash gauge issue if it once worked correctly and now wont..but if it never was "right" or accurate,many things could come into play..
Maybe the dash cluster or temp gauge was swapped from another year truck,and doen't match up to your trucks wiring harness (dash clusters vary between years,or if it had a factory tack,clock,location of gauges,and are wired differently on the printed circuit on the back of the cluster that connects everything to the main harness plug,they have different pinouts..
I've had a few printed circuits get partly smoked when a short happened in a wire under the dash and melted across it--the connections on them are finiky too,its just a strip of copper foil,they corrode or fail sometimes,they may develop high resistance with age too.