This article will show you how to set products to be shown on the Magento categories page even if they are out of stock.
1. Open your Magento Admin Panel.
2. Navigate to Stores > Settings > Configuration
3. In the sidebar on the left-hand side of the screen, scroll down to the Catalog block, expand it if necessary, and click on Inventory.
4. Locate the “Display Out of Stock Products” field. Uncheck the “Use system value” field and change the “Display Out of Stock Products” to Yes.