WordPress keeps deleting .htaccess file

You can give the read-only rights to .htaccess to prevent it from the modifications or removal.

$cd <your website directory>
$chmod 400 .htaccess