Every offseason each team must make a decision which players they can or are willing to keep around. These decisions are typically based on a combination of salary and performance.
There are various reasons why decent players are released by their current teams. It could simply be necessitated by getting under the salary cap or it could be about having enough money available under the cap to sign other players and outside free agents. Other times it’s simply a matter of a team considering a player not worth their salary. That could be due to a point in the player’s contract that gives the team an out.