Strange behavior: random HTTP error 500 fixed by visiting Permalinks settings page (htaccess issue with language code)

Looks like it might be your WPML.

See here: https://wpml.org/forums/topic/wpml-add-rewritebase-en-in-htaccess/

For posterity, the summary of this page is as follows:

Problem: Some wrong settings caused an issue with “Use directory for
default language”. A 500 error was showing. Solution: The client
reports here that pressing the ‘Reset Settings’ button in WPML ->
Languages probably solved the problem.