TLDR they treated him more like an asset than a human being
Only Aiyuk and the NIners FO know the truth so here's my best attempt at objectively pointing out where this relationship went wrong.
Two years ago Aiyuk showed up at practice with black shorts instead of red. Shanahan unloads on him in front of the media and the entire team. Maybe he asked to wear the shorts and was told no and did it anyway. Lots of other possibilities of what led to this moment.
But clearly a decision by shanahan to make an example out of him and quite frankly embarrass him in front of as many people as possible. Again we don't know the full story but simply walking over to him and having a conversation semi privately and asking him to change vs treating him like a dog was a choice shanahan made. Makes you wonder what else was being said behind the scenes and if Aiyuk was truly out of line on a regular basis or if shanahan did this on his own accord.
After his rookie season, he essentially benched him to start the 2021 season and played trent sherfield and Mohamed sanu over him.
One could argue Kyle wanted the team and the media to be aware of his displeasure with Aiyuk for any and everything, more than he wanted to build any sort of relationship with him.
The second piece is Lynch showing up at his house last year Apparently it was unannounced (or after they couldn't reach him) and he wasn't home at the time. Aiyuk described it as his wife calling him a bit uneasy bc lynch is big dude and she was home alone.
Was lynch truly concerned for his well being or just trying to get his asset to fall in line. Not answering your employers calls and texts isn't probably the best idea, but if your boss then showed up unannounced at your house, how would you feel?
Aiyuk certainly doesn't seem like an angel by any means, but when you run back all of these moments there's more of a case for Aiyuk than just focusing on his recent social media nonsense. Did he handle this well, no full stop. Do the niners have any blame in this, perhaps more than the general consensus would suggest. We will never know.