If I move my sites to another server and put a WordPress theme on them, will it affect their rankings?

Moving a site from one server to another won’t affect the rankings much.

However, since your sites are NOT running WordPress currently, changing them involves changing the CMS structure of the site. This may lead to broken links and content change. A drop in rankings may happen when you do this.

However, with a good backlink plan & social signals, you can regain the rankings without much trouble.

When you change your sites to WordPress, you need to make sure that all your URLs are preserved (no URL should go 404). You either need to 301 redirect the current URL to new ones in your newly designed site OR you have to follow the exact same URLs and permalinks which your old site had to be on the safe side