To find Salesforce Permission Sets with Password Never Expires permission enabled, we have to check PermissionsPasswordNeverExpires on the PermissionSet object/entity.
Please check the following SOQL which will retrieve all the Salesforce Permission Sets with the Permission Password Never Expires enabled.
SOQL:
SELECT Id, Name, PermissionsPasswordNeverExpires
FROM PermissionSet
WHERE PermissionsPasswordNeverExpires = true
For Query Salesforce Profiles with Password Never Expires, check the following: