I would say plugins are very easy way to handle membership until unless you want it for a small scale like for few pages/posts etc.
In that case you can register the level of users as per your requirements, assign capabilities and then on each page/post you can check if ( current_user_can() )
This can be a solution to manage to a small scale of things.
A small snippet for this will be
if ( current_user_can( $capability, $args ) ) {
// The code for the page goes here
} else {
// redirect to the home page or to some page telling the user he is not capable to see the page
}
Reference to Current_user_can LINK