Williams, 31, joined Swansea in 2008 and helped them win promotion to the Championship and Premier League as well as the 2013 League Cup.
But the defender said a new challenge and the opportunity to work under Ronald Koeman was too good to turn down.
"I've had eight great years at Swansea and, for me, the new challenge was something I felt I needed, so I'm delighted to have joined Everton," Williams said.
"Everton is a great club with an unbelievable manager -- a world legend in football -- and I believe the club is going in the right direction. This is something I wanted to be a part of.
- Everton (@Everton) August 10, 2016"I look forward to seeing what the manager's plans are for me and the team. He's been one of the greatest centre halves to ever play the game, so I look forward to learning from him and seeing what he can teach me."