Create your quiz with the settings you require, further instructions on this are here: Creating a Quiz
Go into your quiz and in the administration block click "Question bank". This section allows you to create all the questions you would like to pull from for your quiz. If you need more information on the question bank you can visit the Moodle documentation here
Once you have created your question bank, it's time to set up the quiz to pull some random questions from it. In the administration block click "Edit quiz"
At the top right hand corner of the page click "Add" and click "Add a random question"
From the Category dropdown, choose your previously created question bank and set the number of random questions you'd like to include. Click "Add random question".
You now have a quiz with the specified number of random questions you'd like students to answer which are pulled from a bank of questions. There is more information on random quiz questions in the Moodle article here