Hi, you are referring to the ListViewThreshold which, as you say, is limited to 5,000 items per list or library view.
In the scenario above, creating multiple subfolders is effectively partitioning the library, meaning that at any given level in the folder structure, as long as you don't have more than 5,000 items (files or folders) at that level, then you will be fine. Where you would have trouble is if you created a view that flattened the folder structure, returning for instance all documents ordered by most recent created date across all folders...that would throw a ListViewThreshold error.
FYI, if you're browsing the library via the modern library experience then the threshold is increased to, as far I'm aware, 20,000 items. If you are using the classic experience, or some alternative method to query such as programmatically, then it would again revert back to 5,000.
It's worth noting separately that although the above may work from a threshold perspective, if you are expecting to store that volume of files in a single library, you need to consider what happens if someone chooses to sync the whole library. OneDrive has its own limitations, in that if you try and sync a library (or even or a subfolder within a library) that has more than 100,000 items you will start to experience some serious performance impacts. If there is an option for you to create multiple document libraries at the first layer of the structure, instead of a single library with folders, this will reduce the likelihood of users simply syncing everything