Salesforce uses two database tables, the IDEWorkspace (e.g. Id=1de000000012345) and IDEPerspective (e.g. Id=1dg000000012345) objects to keep track of your Developer Console state. It's supposed to save periodically/automatically. These settings are per-user, so if you're sharing your login with another developer, they could be overwriting your settings. Also, having more than one copy of Developer Console logged in at once tends to cause problems.
When everything works well, it remembers the files you have open, including any edits, recently used queries, the recent Execute Anonymous script, etc. I haven't found any pattern to this, aside from using multiple windows (e.g. actual multiple copies of DC open in multiple tabs), a spotty Internet connection, or a "bad workspace," and these days, I prefer to simply use VS Code and SFDX for any serious development, so it's less relevant, as VS Code always remembers your open files and workspace configuration by default.
If you're having troubles with your state saving/loading, you can try deleting your workspace, as outlined in 000332898.
Developer Console menu may become non-functional sometimes, because of the workspace being in bad state. To restore the functionality, follow the following steps.
Fix 1:
Login and open Developer Console by Chrome
Open Developer tools and select Network
Reload on Developer Console
Fix 2:
Login to Workbench and go to REST Explorer
Use the following query in Workbench to get the IDEWorkspace
/services/data/v31.0/tooling/query/?q=SELECT id, name from IDEWorkspace
ID of IDEWorkspace is "1dexxxxxxxxxxxxxx".
Do GET operation for the found id with following query "/services/data/v29.0/tooling/sobjects/IDEWorkspace/1de1a0000014sEWAAY"
You will see the content of IDEWorkspace
Do DELETE operation on found record.
Re-open Developer Console.
Developer Console will work fine. As we created a new workspace and the old workspace has been deleted.And the slowness will also be removed.