In essence what you are doing is playing "play pretend", just like you did when you were a kid. You imagine a world, and are pretending to be in it. Of course, to make it a game suitable for multiple players you want some structure in the form of rules. You can choose to make those rules up yourself, or you can use the rules someone else has written. (e.g. one or more of the D&D books, but there's plenty others).
After that, you will want some challenges for you and your players: monsters! You can make them up yourself, or you can find them in books written by others. (e.g. Monsters Manual for D&D)
Then, you want a world to play in, accompanied by a story. Same here: you can make a world and a story up yourself, or you can consult a book that someone else has written for you. (E.g. Lost Mines of Phandelver (LMOP))

You have the choice to do it yourself or to consult something else in pretty much every step of the game. You can also mix. E.g. use the rules from the PHB, but with homebrew changes. Or use the LMOP campaign, but with a big flying gummybear instead of a dragon. It's all up to you and your imagination.