Extension:NamespaceReadRestrict

The NamespaceReadRestrict extension can allow reading of pages in particular namespaces, but not others.

Configuration
In accordance with the instructions at Manual:Preventing access, abolish the ability of non-logged-in users to read, edit or create accounts on your wiki and initialize the $wgWhitelistRead array (it must be initialized, even if it's empty, in order for this extension to work) by adding to your LocalSettings.php file the following:

If most of your content will be private
Also add to LocalSettings.php, after the  line, this configuration setting specifying what namespaces are okay for non-logged-in users to read. E.g. in this example, non-logged-in users will only be allowed to read pages in namespace 0, the main namespace. See Manual:Namespace and Manual:Using custom namespaces.

If most of your content will be public
If most of your wiki content will be open to the public, then you may want to establish a Private: namespace for the rest. Conversely, if you want most of your wiki to be private, then you might want to establish a Public: namespace for the rest. Don't forget about $wgNonincludableNamespaces, if you've left open the option of non-logged-in users to edit. E.g.:

Parser function
There is a parser function,. If you also have Extension:ParserFunctions installed, then you can use this to, for example, give logged-in users and non-logged-in users different main pages. To do that, you would create pages "Template:Private main page" and "Template:Public main page" and then replace the content of "Main Page" with:

Alternatives
An alternative solution that utilises MW in-built since v1.21.0 functionality might be to affect a general reading restriction on the wiki by then excluding specific namespaces from that restriction by the configuration setting $wgWhitelistReadRegexp.